make Reporting take a Procdesc instead of attributes

Summary: This is simpler for almost all call sites.

Reviewed By: ezgicicek

Differential Revision: D21425591

fbshipit-source-id: 60b8d0e16
master
Jules Villard 5 years ago committed by Facebook GitHub Bot
parent 15a85a1734
commit e06487868b

@ -23,8 +23,8 @@ let log_frontend_issue severity errlog ~loc ~node_key ~ltr exn =
log_issue_from_errlog severity errlog ~loc ~node ~session:0 ~ltr ~access:None ~extras:None exn
let log_issue_from_summary severity proc_attributes err_log ~node ~session ~loc ~ltr ?extras exn =
let procname = proc_attributes.ProcAttributes.proc_name in
let log_issue_from_summary severity proc_desc err_log ~node ~session ~loc ~ltr ?extras exn =
let procname = Procdesc.get_proc_name proc_desc in
let is_java_generated_method =
match procname with
| Procname.Java java_pname ->
@ -41,7 +41,8 @@ let log_issue_from_summary severity proc_attributes err_log ~node ~session ~loc
in
let should_suppress_lint =
Language.curr_language_is Java
&& Annotations.ia_is_suppress_lint proc_attributes.ProcAttributes.method_annotation.return
&& Annotations.ia_is_suppress_lint
(Procdesc.get_attributes proc_desc).ProcAttributes.method_annotation.return
in
if should_suppress_lint || is_java_generated_method || is_java_external_package then
Logging.debug Analysis Medium "Reporting is suppressed!@\n" (* Skip the reporting *)

@ -13,7 +13,7 @@ type log_t = ?ltr:Errlog.loc_trace -> ?extras:Jsonbug_t.extra -> IssueType.t ->
val log_issue_from_summary :
Exceptions.severity
-> ProcAttributes.t
-> Procdesc.t
-> Errlog.t
-> node:Errlog.node
-> session:int
@ -33,10 +33,10 @@ val log_frontend_issue :
-> unit
(** Report a frontend issue of a given kind in the given error log. *)
val log_error : ProcAttributes.t -> Errlog.t -> loc:Location.t -> log_t
val log_error : Procdesc.t -> Errlog.t -> loc:Location.t -> log_t
(** Add an error to the given error log. *)
val log_warning : ProcAttributes.t -> Errlog.t -> loc:Location.t -> log_t
val log_warning : Procdesc.t -> Errlog.t -> loc:Location.t -> log_t
(** Add a warning to the given error log. *)
val log_issue_external :

@ -1138,9 +1138,8 @@ let check_junk {InterproceduralAnalysis.proc_desc; err_log; tenv} prop =
let report_leak () =
if not report_and_continue then raise exn
else (
BiabductionReporting.log_issue_deprecated_using_state
(Procdesc.get_attributes proc_desc)
err_log Exceptions.Error exn ;
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log
Exceptions.Error exn ;
leaks_reported := alloc_attribute :: !leaks_reported )
in
if not ignore_leak then report_leak () ;

@ -7,7 +7,7 @@
open! IStd
let log_issue_deprecated_using_state proc_attributes err_log severity ?node ?loc ?ltr exn =
let log_issue_deprecated_using_state proc_desc err_log severity ?node ?loc ?ltr exn =
if !BiabductionConfig.footprint then
let node =
let node = match node with None -> AnalysisState.get_node_exn () | Some node -> node in
@ -16,7 +16,7 @@ let log_issue_deprecated_using_state proc_attributes err_log severity ?node ?loc
let session = AnalysisState.get_session () in
let loc = match loc with None -> AnalysisState.get_loc_exn () | Some loc -> loc in
let ltr = match ltr with None -> State.get_loc_trace () | Some ltr -> ltr in
Reporting.log_issue_from_summary severity proc_attributes err_log ~node ~session ~loc ~ltr exn
Reporting.log_issue_from_summary severity proc_desc err_log ~node ~session ~loc ~ltr exn
let log_error_using_state proc_desc err_log exn =
@ -30,5 +30,4 @@ let log_error_using_state proc_desc err_log exn =
match AnalysisState.get_loc () with Some l -> l | None -> Procdesc.Node.get_loc node'
in
let ltr = State.get_loc_trace () in
let attrs = Procdesc.get_attributes proc_desc in
Reporting.log_issue_from_summary Exceptions.Error attrs err_log ~node ~session ~loc ~ltr exn
Reporting.log_issue_from_summary Exceptions.Error proc_desc err_log ~node ~session ~loc ~ltr exn

@ -11,7 +11,7 @@ val log_error_using_state : Procdesc.t -> Errlog.t -> exn -> unit
(** Add an error to the given summary using biabduction state. *)
val log_issue_deprecated_using_state :
ProcAttributes.t
Procdesc.t
-> Errlog.t
-> Exceptions.severity
-> ?node:Procdesc.Node.t

@ -2574,8 +2574,7 @@ let check_implication_base {InterproceduralAnalysis.proc_desc; err_log; tenv} ch
L.d_printfln "WARNING: footprint failed to find MISSING because: %s" s ;
None
| Exceptions.Abduction_case_not_implemented _ as exn ->
let proc_attrs = Procdesc.get_attributes proc_desc in
BiabductionReporting.log_issue_deprecated_using_state proc_attrs err_log Exceptions.Error exn ;
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Exceptions.Error exn ;
None

@ -55,9 +55,7 @@ let check_bad_index {InterproceduralAnalysis.proc_desc; err_log; tenv} pname p l
Exceptions.Array_out_of_bounds_l1
(Errdesc.explain_array_access pname tenv deref_str p loc, __POS__)
in
let proc_attrs = Procdesc.get_attributes proc_desc in
BiabductionReporting.log_issue_deprecated_using_state proc_attrs err_log Exceptions.Warning
exn
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Exceptions.Warning 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 pname tenv deref_str p loc in
@ -65,9 +63,7 @@ let check_bad_index {InterproceduralAnalysis.proc_desc; err_log; tenv} pname p l
if index_has_bounds () then Exceptions.Array_out_of_bounds_l2 (desc, __POS__)
else Exceptions.Array_out_of_bounds_l3 (desc, __POS__)
in
let proc_attrs = Procdesc.get_attributes proc_desc in
BiabductionReporting.log_issue_deprecated_using_state proc_attrs err_log Exceptions.Warning
exn
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Exceptions.Warning exn
(** Perform bounds checking *)
@ -1008,8 +1004,8 @@ let check_type_size {InterproceduralAnalysis.proc_desc; err_log; tenv} pname pro
Exceptions.Pointer_size_mismatch
(Errdesc.explain_dereference pname tenv deref_str prop loc, __POS__)
in
let attrs = Procdesc.get_attributes proc_desc in
BiabductionReporting.log_issue_deprecated_using_state attrs err_log Exceptions.Warning exn
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Exceptions.Warning
exn
| None ->
L.d_str "texp: " ; Exp.d_texp_full texp ; L.d_ln ()

@ -344,8 +344,7 @@ let check_inherently_dangerous_function {InterproceduralAnalysis.proc_desc; err_
Exceptions.Inherently_dangerous_function
(Localise.desc_inherently_dangerous_function callee_pname)
in
let attrs = Procdesc.get_attributes proc_desc in
BiabductionReporting.log_issue_deprecated_using_state attrs err_log Exceptions.Warning exn
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Exceptions.Warning exn
let reason_to_skip ~callee_desc : string option =
@ -410,8 +409,7 @@ let check_arith_norm_exp {InterproceduralAnalysis.proc_desc; err_log; tenv} exp
(AnalysisState.get_loc_exn ())
in
let exn = Exceptions.Divide_by_zero (desc, __POS__) in
let attrs = Procdesc.get_attributes proc_desc in
BiabductionReporting.log_issue_deprecated_using_state attrs err_log Exceptions.Warning exn ;
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Exceptions.Warning exn ;
(Prop.exp_normalize_prop tenv prop exp, prop')
| Some (Attribute.UminusUnsigned (e, typ)), prop' ->
let desc =
@ -419,8 +417,7 @@ let check_arith_norm_exp {InterproceduralAnalysis.proc_desc; err_log; tenv} exp
(AnalysisState.get_node_exn ()) (AnalysisState.get_loc_exn ())
in
let exn = Exceptions.Unary_minus_applied_to_unsigned_expression (desc, __POS__) in
let attrs = Procdesc.get_attributes proc_desc in
BiabductionReporting.log_issue_deprecated_using_state attrs err_log Exceptions.Warning exn ;
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Exceptions.Warning exn ;
(Prop.exp_normalize_prop tenv prop exp, prop')
| None, prop' ->
(Prop.exp_normalize_prop tenv prop exp, prop')
@ -478,8 +475,7 @@ let check_already_dereferenced {InterproceduralAnalysis.proc_desc; err_log; tenv
(AnalysisState.get_node_exn ()) n (AnalysisState.get_loc_exn ())
in
let exn = Exceptions.Null_test_after_dereference (desc, __POS__) in
let attrs = Procdesc.get_attributes proc_desc in
BiabductionReporting.log_issue_deprecated_using_state attrs err_log Exceptions.Warning exn
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Exceptions.Warning exn
| None ->
()
@ -1209,8 +1205,8 @@ let rec sym_exec
ret_id_typ ret_typ actual_args =
let skip_res () =
let exn = Exceptions.Skip_function (Localise.desc_skip_function callee_pname) in
let attrs = Procdesc.get_attributes current_pdesc in
BiabductionReporting.log_issue_deprecated_using_state attrs err_log Exceptions.Info exn ;
BiabductionReporting.log_issue_deprecated_using_state current_pdesc err_log Exceptions.Info
exn ;
L.d_printfln "Skipping function '%a': %s" Procname.pp callee_pname reason ;
unknown_or_scan_call ~is_scan:false ~reason ret_typ ret_annots
{ Builtin.instr
@ -1261,9 +1257,8 @@ let rec sym_exec
let exn =
Exceptions.Condition_always_true_false (desc, not (IntLit.iszero i), __POS__)
in
let attrs = Procdesc.get_attributes current_pdesc in
BiabductionReporting.log_issue_deprecated_using_state attrs err_log Exceptions.Warning
exn
BiabductionReporting.log_issue_deprecated_using_state current_pdesc err_log
Exceptions.Warning exn
| _ ->
()
in

@ -401,9 +401,8 @@ let check_path_errors_in_post {InterproceduralAnalysis.proc_desc= caller_pdesc;
in
State.set_path new_path path_pos_opt ;
let exn = Exceptions.Divide_by_zero (desc, __POS__) in
let attrs = Procdesc.get_attributes caller_pdesc in
BiabductionReporting.log_issue_deprecated_using_state attrs err_log Exceptions.Warning exn
)
BiabductionReporting.log_issue_deprecated_using_state caller_pdesc err_log
Exceptions.Warning exn )
| _ ->
()
in
@ -1131,8 +1130,8 @@ let exe_spec
missing_sigma_objc_class callee_summary ) ;
let log_check_exn check =
let exn = get_check_exn tenv check callee_pname loc __POS__ in
let attrs = Procdesc.get_attributes caller_pdesc in
BiabductionReporting.log_issue_deprecated_using_state attrs err_log Exceptions.Warning exn
BiabductionReporting.log_issue_deprecated_using_state caller_pdesc err_log
Exceptions.Warning exn
in
let do_split () =
process_splitting actual_pre sub1 sub2 frame missing_pi missing_sigma frame_fld missing_fld

@ -402,8 +402,7 @@ let forward_tabulate ({InterproceduralAnalysis.proc_desc; err_log; tenv; _} as a
L.d_strln "SIL INSTR:" ;
Procdesc.Node.d_instrs ~highlight:(AnalysisState.get_instr ()) curr_node ;
L.d_ln () ;
let attrs = Procdesc.get_attributes proc_desc in
BiabductionReporting.log_issue_deprecated_using_state attrs err_log Exceptions.Error exn ;
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Exceptions.Error exn ;
State.mark_instr_fail exn
in
let exe_iter f pathset =
@ -488,8 +487,7 @@ let remove_locals_formals_and_check {InterproceduralAnalysis.proc_desc; err_log;
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
let attrs = Procdesc.get_attributes proc_desc in
BiabductionReporting.log_issue_deprecated_using_state attrs err_log Exceptions.Warning exn
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Exceptions.Warning exn
in
List.iter ~f:check_pvar pvars ; p'
@ -796,9 +794,8 @@ let perform_analysis_phase ({InterproceduralAnalysis.proc_desc; err_log; tenv} a
forward_tabulate analysis_data proc_cfg summary_opt wl
in
let get_results (wl : Worklist.t) () =
let attrs = Procdesc.get_attributes proc_desc in
State.process_execution_failures
(BiabductionReporting.log_issue_deprecated_using_state attrs err_log Exceptions.Warning) ;
(BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Exceptions.Warning) ;
let results = collect_analysis_result analysis_data wl proc_cfg in
let specs =
try extract_specs analysis_data (ProcCfg.Exceptional.proc_desc proc_cfg) results
@ -807,7 +804,8 @@ let perform_analysis_phase ({InterproceduralAnalysis.proc_desc; err_log; tenv} a
Exceptions.Internal_error
(Localise.verbatim_desc "Leak_while_collecting_specs_after_footprint")
in
BiabductionReporting.log_issue_deprecated_using_state attrs err_log Exceptions.Error exn ;
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Exceptions.Error
exn ;
(* returning no specs *) []
in
(specs, BiabductionSummary.FOOTPRINT)
@ -923,8 +921,7 @@ let report_custom_errors {InterproceduralAnalysis.proc_desc; err_log; tenv} summ
let loc = Procdesc.get_loc proc_desc in
let err_desc = Localise.desc_custom_error loc in
let exn = Exceptions.Custom_error (custom_error, err_desc) in
let attrs = Procdesc.get_attributes proc_desc in
BiabductionReporting.log_issue_deprecated_using_state attrs err_log Exceptions.Error exn
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Exceptions.Error exn
in
List.iter ~f:report error_preconditions

@ -36,8 +36,7 @@ module UnusedBranch = struct
if true_branch then IssueType.condition_always_false else IssueType.condition_always_true
in
let ltr = [Errlog.make_trace_element 0 location "Here" []] in
let attrs = Procdesc.get_attributes proc_desc in
Reporting.log_warning attrs err_log ~loc:location ~ltr issue_type desc
Reporting.log_warning proc_desc err_log ~loc:location ~ltr issue_type desc
end
module UnusedBranches = struct
@ -54,8 +53,7 @@ module UnreachableStatement = struct
let report {InterproceduralAnalysis.proc_desc; err_log} {location} =
let ltr = [Errlog.make_trace_element 0 location "Here" []] in
let attrs = Procdesc.get_attributes proc_desc in
Reporting.log_error attrs err_log ~loc:location ~ltr IssueType.unreachable_code_after
Reporting.log_error proc_desc err_log ~loc:location ~ltr IssueType.unreachable_code_after
"Unreachable code after statement"
end
@ -408,8 +406,8 @@ let report_errors ({InterproceduralAnalysis.proc_desc; err_log} as analysis_data
Trace.Issue.make_err_trace ~description (PO.ConditionTrace.get_val_traces trace)
|> Errlog.concat_traces
in
let attrs = Procdesc.get_attributes proc_desc in
Reporting.log_error attrs err_log ~loc:location ~ltr:trace issue_type (description ~markup:true)
Reporting.log_error proc_desc err_log ~loc:location ~ltr:trace issue_type
(description ~markup:true)
in
PO.ConditionSet.report_errors ~report cond_set

@ -59,7 +59,7 @@ let get_required_props typename tenv =
[]
let report_missing_required_prop proc_attrs err_log prop parent_typename ~create_loc call_chain =
let report_missing_required_prop proc_desc err_log prop parent_typename ~create_loc call_chain =
let message =
let prop_string =
match prop with
@ -82,8 +82,7 @@ let report_missing_required_prop proc_attrs err_log prop parent_typename ~create
in
Errlog.make_trace_element 0 location call_msg [] )
in
Reporting.log_error proc_attrs err_log ~loc:create_loc ~ltr IssueType.missing_required_prop
message
Reporting.log_error proc_desc err_log ~loc:create_loc ~ltr IssueType.missing_required_prop message
let has_prop prop_set prop =
@ -182,10 +181,9 @@ let should_report proc_desc tenv =
let report {InterproceduralAnalysis.proc_desc; tenv; err_log} astate =
let check_on_string_set parent_typename create_loc call_chain prop_set =
let required_props = get_required_props parent_typename tenv in
let attrs = Procdesc.get_attributes proc_desc in
List.iter required_props ~f:(fun required_prop ->
if not (has_prop prop_set required_prop) then
report_missing_required_prop attrs err_log required_prop parent_typename ~create_loc
report_missing_required_prop proc_desc err_log required_prop parent_typename ~create_loc
call_chain )
in
Domain.check_required_props ~check_on_string_set astate

@ -229,7 +229,7 @@ module TransferFunctions = struct
Location.compare loc1 loc2 )
let report_unchecked_strongself_issues attributes err_log (domain : Domain.t) var_use var =
let report_unchecked_strongself_issues proc_desc err_log (domain : Domain.t) var_use var =
match find_strong_var domain var with
| Some ({DomainData.pvar; loc; kind}, _, strongVarElem)
when DomainData.is_unchecked_strong_self kind && not strongVarElem.reported ->
@ -240,7 +240,7 @@ module TransferFunctions = struct
(Pvar.pp Pp.text) pvar var_use Location.pp loc
in
let ltr = make_trace_unchecked_strongself domain in
Reporting.log_error attributes err_log ~ltr ~loc IssueType.strong_self_not_checked message ;
Reporting.log_error proc_desc err_log ~ltr ~loc IssueType.strong_self_not_checked message ;
let strongVars =
StrongEqualToWeakCapturedVars.add pvar
{strongVarElem with reported= true}
@ -251,12 +251,12 @@ module TransferFunctions = struct
domain
let report_unchecked_strongself_issues_on_exps attributes err_log (domain : Domain.t)
let report_unchecked_strongself_issues_on_exps proc_desc err_log (domain : Domain.t)
(instr : Sil.instr) =
let report_unchecked_strongself_issues_on_exp strongVars (exp : Exp.t) =
match exp with
| Lfield (Var var, _, _) ->
report_unchecked_strongself_issues attributes err_log domain "dereferenced" var
report_unchecked_strongself_issues proc_desc err_log domain "dereferenced" var
| _ ->
strongVars
in
@ -306,9 +306,9 @@ module TransferFunctions = struct
None
let report_unchecked_strongself_issues_on_args attributes err_log (domain : Domain.t) pname args =
let report_unchecked_strongself_issues_on_args proc_desc err_log (domain : Domain.t) pname args =
let report_issue var =
report_unchecked_strongself_issues attributes err_log domain
report_unchecked_strongself_issues proc_desc err_log domain
(F.sprintf "passed to `%s`" (Procname.to_simplified_string pname))
var
in
@ -346,7 +346,7 @@ module TransferFunctions = struct
let exec_instr (astate : Domain.t) {IntraproceduralAnalysis.proc_desc; err_log} _cfg_node
(instr : Sil.instr) =
let attributes = Procdesc.get_attributes proc_desc in
let astate = report_unchecked_strongself_issues_on_exps attributes err_log astate instr in
let astate = report_unchecked_strongself_issues_on_exps proc_desc err_log astate instr in
let astate = remove_ids_in_closures_from_domain astate instr in
match instr with
| Load {id; e= Lvar pvar; loc; typ} ->
@ -387,7 +387,7 @@ module TransferFunctions = struct
| Prune (UnOp (LNot, BinOp (Binop.Eq, Var id, e), _), _, _, _) ->
if Exp.is_null_literal e then exec_null_check_id astate id else astate
| Call (_, Exp.Const (Const.Cfun callee_pn), args, _, _) ->
report_unchecked_strongself_issues_on_args attributes err_log astate callee_pn args
report_unchecked_strongself_issues_on_args proc_desc err_log astate callee_pn args
| _ ->
astate
end
@ -426,7 +426,7 @@ let make_trace_captured_strong_self domain =
Location.compare loc1 loc2 )
let report_mix_self_weakself_issues attributes err_log domain (weakSelf : DomainData.t)
let report_mix_self_weakself_issues proc_desc err_log domain (weakSelf : DomainData.t)
(self : DomainData.t) =
let message =
F.asprintf
@ -436,10 +436,10 @@ let report_mix_self_weakself_issues attributes err_log domain (weakSelf : Domain
Location.pp self.loc
in
let ltr = make_trace_use_self_weakself domain in
Reporting.log_error attributes err_log ~ltr ~loc:self.loc IssueType.mixed_self_weakself message
Reporting.log_error proc_desc err_log ~ltr ~loc:self.loc IssueType.mixed_self_weakself message
let report_weakself_in_no_escape_block_issues attributes err_log domain (weakSelf : DomainData.t)
let report_weakself_in_no_escape_block_issues proc_desc err_log domain (weakSelf : DomainData.t)
procname reported_weak_self_in_noescape_block =
if not (Pvar.Set.mem weakSelf.pvar reported_weak_self_in_noescape_block) then (
let reported_weak_self_in_noescape_block =
@ -453,13 +453,13 @@ let report_weakself_in_no_escape_block_issues attributes err_log domain (weakSel
(Procname.to_simplified_string procname)
in
let ltr = make_trace_use_self_weakself domain in
Reporting.log_error attributes err_log ~ltr ~loc:weakSelf.loc
Reporting.log_error proc_desc err_log ~ltr ~loc:weakSelf.loc
IssueType.weak_self_in_noescape_block message ;
reported_weak_self_in_noescape_block )
else reported_weak_self_in_noescape_block
let report_weakself_multiple_issue attributes err_log domain (weakSelf1 : DomainData.t)
let report_weakself_multiple_issue proc_desc err_log domain (weakSelf1 : DomainData.t)
(weakSelf2 : DomainData.t) =
let message =
F.asprintf
@ -471,11 +471,12 @@ let report_weakself_multiple_issue attributes err_log domain (weakSelf1 : Domain
(Pvar.pp Pp.text) weakSelf1.pvar (Pvar.pp Pp.text) weakSelf1.pvar
in
let ltr = make_trace_use_self_weakself domain in
Reporting.log_error attributes err_log ~ltr ~loc:weakSelf1.loc IssueType.multiple_weakself message
Reporting.log_error proc_desc err_log ~ltr ~loc:weakSelf1.loc IssueType.multiple_weakself message
let report_captured_strongself_issue attributes err_log domain (capturedStrongSelf : DomainData.t)
let report_captured_strongself_issue proc_desc err_log domain (capturedStrongSelf : DomainData.t)
report_captured_strongself =
let attributes = Procdesc.get_attributes proc_desc in
if
Option.is_none attributes.ProcAttributes.passed_as_noescape_block_to
&& not (Pvar.Set.mem capturedStrongSelf.pvar report_captured_strongself)
@ -491,26 +492,27 @@ let report_captured_strongself_issue attributes err_log domain (capturedStrongSe
(Pvar.pp Pp.text) capturedStrongSelf.pvar Location.pp capturedStrongSelf.loc
in
let ltr = make_trace_captured_strong_self domain in
Reporting.log_error attributes err_log ~ltr ~loc:capturedStrongSelf.loc
Reporting.log_error proc_desc err_log ~ltr ~loc:capturedStrongSelf.loc
IssueType.captured_strong_self message ;
report_captured_strongself )
else report_captured_strongself
let report_issues attributes err_log domain =
let report_issues proc_desc err_log domain =
let process_domain_item (result : report_issues_result) (_, (domain_data : DomainData.t)) =
match domain_data.kind with
| DomainData.CAPTURED_STRONG_SELF ->
let reported_captured_strong_self =
report_captured_strongself_issue attributes err_log domain domain_data
report_captured_strongself_issue proc_desc err_log domain domain_data
result.reported_captured_strong_self
in
{result with reported_captured_strong_self}
| DomainData.WEAK_SELF ->
let reported_weak_self_in_noescape_block =
let attributes = Procdesc.get_attributes proc_desc in
match attributes.ProcAttributes.passed_as_noescape_block_to with
| Some procname ->
report_weakself_in_no_escape_block_issues attributes err_log domain domain_data
report_weakself_in_no_escape_block_issues proc_desc err_log domain domain_data
procname result.reported_weak_self_in_noescape_block
| None ->
result.reported_weak_self_in_noescape_block
@ -541,12 +543,12 @@ let report_issues attributes err_log domain =
let selfList = List.rev selfList in
( match (weakSelfList, selfList) with
| weakSelf :: _, self :: _ ->
report_mix_self_weakself_issues attributes err_log domain weakSelf self
report_mix_self_weakself_issues proc_desc err_log domain weakSelf self
| _ ->
() ) ;
match weakSelfList with
| weakSelf1 :: weakSelf2 :: _ ->
report_weakself_multiple_issue attributes err_log domain weakSelf1 weakSelf2
report_weakself_multiple_issue proc_desc err_log domain weakSelf1 weakSelf2
| _ ->
()
@ -559,7 +561,6 @@ let checker ({IntraproceduralAnalysis.proc_desc; err_log} as analysis_data) =
if Procname.is_objc_block procname then
match Analyzer.compute_post analysis_data ~initial proc_desc with
| Some domain ->
let attributes = Procdesc.get_attributes proc_desc in
report_issues attributes err_log domain.vars
report_issues proc_desc err_log domain.vars
| None ->
()

@ -231,8 +231,7 @@ let report_siof {InterproceduralAnalysis.proc_desc; err_log; analyze_dependency;
GlobalVar.pp (SiofTrace.Sink.kind final_sink)
in
let ltr = SiofTrace.trace_of_error loc gname trace in
let attrs = Procdesc.get_attributes proc_desc in
Reporting.log_error attrs err_log ~loc ~ltr IssueType.static_initialization_order_fiasco
Reporting.log_error proc_desc err_log ~loc ~ltr IssueType.static_initialization_order_fiasco
description
in
let reportable_paths = SiofTrace.get_reportable_sink_paths trace ~trace_of_pname in

@ -85,8 +85,7 @@ let report_allocation_stack {InterproceduralAnalysis.proc_desc; err_log} src_ann
MF.pp_monospaced ("@" ^ src_annot) MF.pp_monospaced constr_str MF.pp_monospaced
("new " ^ constr_str)
in
let attrs = Procdesc.get_attributes proc_desc in
Reporting.log_error attrs err_log ~loc:fst_call_loc ~ltr:final_trace
Reporting.log_error proc_desc err_log ~loc:fst_call_loc ~ltr:final_trace
IssueType.checkers_allocates_memory description
@ -110,8 +109,7 @@ let report_annotation_stack ({InterproceduralAnalysis.proc_desc; err_log} as ana
IssueType.checkers_calls_expensive_method
else IssueType.checkers_annotation_reachability_error
in
let attrs = Procdesc.get_attributes proc_desc in
Reporting.log_error attrs err_log ~loc ~ltr:final_trace issue_type description
Reporting.log_error proc_desc err_log ~loc ~ltr:final_trace issue_type description
let report_call_stack end_of_stack lookup_next_calls report call_site sink_map =
@ -333,8 +331,7 @@ module CxxAnnotationSpecs = struct
let linters_def_file = Option.value_map ~default:"" ~f:Fn.id Config.inferconfig_file in
IssueType.register_from_string spec_name ~doc_url ~linters_def_file
in
let attrs = Procdesc.get_attributes proc_desc in
Reporting.log_error attrs err_log ~loc ~ltr:final_trace issue_type description
Reporting.log_error proc_desc err_log ~loc ~ltr:final_trace issue_type description
in
let snk_annot = annotation_of_str snk_name in
let report ({InterproceduralAnalysis.proc_desc} as analysis_data) annot_map =
@ -412,8 +409,7 @@ module ExpensiveAnnotationSpec = struct
(Procname.to_string overridden_pname)
MF.pp_monospaced ("@" ^ Annotations.expensive)
in
let attrs = Procdesc.get_attributes proc_desc in
Reporting.log_error attrs err_log ~loc IssueType.checkers_expensive_overrides_unexpensive
Reporting.log_error proc_desc err_log ~loc IssueType.checkers_expensive_overrides_unexpensive
description

@ -111,8 +111,7 @@ let report_loads {InterproceduralAnalysis.proc_desc; err_log} astate =
else
let ltr = ClassLoadsDomain.Event.make_loc_trace event in
let msg = Format.asprintf "Class %s loaded" elem in
let attrs = Procdesc.get_attributes proc_desc in
Reporting.log_warning attrs err_log ~loc ~ltr IssueType.class_load msg
Reporting.log_warning proc_desc err_log ~loc ~ltr IssueType.class_load msg
in
let pname = Procdesc.get_proc_name proc_desc in
Procname.get_class_name pname

@ -31,7 +31,7 @@ let format_method pname =
Procname.to_string pname
let report_warning ({ProcAttributes.proc_name; loc} as attrs) err_log class_name fld fld_typ =
let report_warning proc_desc err_log class_name fld fld_typ =
let pp_m = MarkupFormatter.pp_monospaced in
let description =
Format.asprintf
@ -39,9 +39,12 @@ let report_warning ({ProcAttributes.proc_name; loc} as attrs) err_log class_name
the back stack, a reference to this (probably dead) View will be retained. In general, it \
is a good idea to initialize View's in %a, then nullify them in %a."
pp_m (Typ.Name.name class_name) pp_m (Fieldname.get_field_name fld) pp_m (format_typ fld_typ)
pp_m (format_method proc_name) pp_m on_create_view pp_m on_destroy_view
pp_m
(format_method (Procdesc.get_proc_name proc_desc))
pp_m on_create_view pp_m on_destroy_view
in
Reporting.log_warning attrs err_log ~loc IssueType.checkers_fragment_retain_view description
Reporting.log_warning proc_desc err_log ~loc:(Procdesc.get_loc proc_desc)
IssueType.checkers_fragment_retain_view description
let callback_fragment_retains_view_java {IntraproceduralAnalysis.proc_desc; tenv; err_log}
@ -74,9 +77,7 @@ let callback_fragment_retains_view_java {IntraproceduralAnalysis.proc_desc; tenv
not
( Annotations.ia_ends_with ia Annotations.auto_cleanup
|| Fieldname.Set.mem fname fields_nullified )
then
let attrs = Procdesc.get_attributes proc_desc in
report_warning attrs err_log class_name fname fld_typ )
then report_warning proc_desc err_log class_name fname fld_typ )
declared_view_fields
| _ ->
()

@ -164,21 +164,20 @@ let extract_impurity tenv pdesc (exec_state : ExecutionDomain.t) : ImpurityDomai
let checker {IntraproceduralAnalysis.proc_desc; tenv; err_log} pulse_summary_opt =
let proc_name = Procdesc.get_proc_name proc_desc in
let pname_loc = Procdesc.get_loc proc_desc in
let attrs = Procdesc.get_attributes proc_desc in
match pulse_summary_opt with
| None ->
let impure_fun_desc =
F.asprintf "Impure function %a with no pulse summary" Procname.pp proc_name
in
let impure_fun_ltr = Errlog.make_trace_element 0 pname_loc impure_fun_desc [] in
Reporting.log_error attrs err_log ~loc:pname_loc ~ltr:[impure_fun_ltr]
Reporting.log_error proc_desc err_log ~loc:pname_loc ~ltr:[impure_fun_ltr]
IssueType.impure_function impure_fun_desc
| Some [] ->
let impure_fun_desc =
F.asprintf "Impure function %a with empty pulse summary" Procname.pp proc_name
in
let impure_fun_ltr = Errlog.make_trace_element 0 pname_loc impure_fun_desc [] in
Reporting.log_error attrs err_log ~loc:pname_loc ~ltr:[impure_fun_ltr]
Reporting.log_error proc_desc err_log ~loc:pname_loc ~ltr:[impure_fun_ltr]
IssueType.impure_function impure_fun_desc
| Some pre_posts ->
let (ImpurityDomain.{modified_globals; modified_params; skipped_calls} as impurity_astate) =
@ -208,5 +207,5 @@ let checker {IntraproceduralAnalysis.proc_desc; tenv; err_log} pulse_summary_opt
:: modified_ltr Formal modified_params
(modified_ltr Global modified_globals skipped_functions)
in
Reporting.log_error attrs err_log ~loc:pname_loc ~ltr IssueType.impure_function
Reporting.log_error proc_desc err_log ~loc:pname_loc ~ltr IssueType.impure_function
impure_fun_desc

@ -52,7 +52,7 @@ let find_first_arg_pvar node ~fun_name ~class_name_f =
else None
let report_matching_get attrs err_log tenv pvar loop_nodes : unit =
let report_matching_get proc_desc err_log tenv pvar loop_nodes : unit =
LoopNodes.iter
(fun node ->
let instrs = Procdesc.Node.get_instrs node in
@ -75,7 +75,7 @@ let report_matching_get attrs err_log tenv pvar loop_nodes : unit =
in
let loc = Procdesc.Node.get_loc node in
let ltr = [Errlog.make_trace_element 0 loc exp_desc []] in
Reporting.log_error attrs err_log ~loc ~ltr
Reporting.log_error proc_desc err_log ~loc ~ltr
IssueType.inefficient_keyset_iterator exp_desc ) ) )
loop_nodes
@ -106,7 +106,6 @@ let checker {IntraproceduralAnalysis.proc_desc; tenv; err_log} =
let cfg = CFG.from_pdesc proc_desc in
let _, loop_head_to_loop_nodes = Loop_control.get_loop_control_maps cfg in
let idom = Dominators.get_idoms proc_desc in
let attrs = Procdesc.get_attributes proc_desc in
Procdesc.NodeMap.iter
(fun loop_head loop_nodes ->
if
@ -118,5 +117,5 @@ let checker {IntraproceduralAnalysis.proc_desc; tenv; err_log} =
~class_name_f:(PatternMatch.implements_set tenv) ~f:(fun itr_node _ ->
when_dominating_preds_satisfy idom itr_node ~fun_name:"keySet"
~class_name_f:(implements_map tenv) ~f:(fun _keySet_node get_pvar ->
report_matching_get attrs err_log tenv get_pvar loop_nodes ) ) )
report_matching_get proc_desc err_log tenv get_pvar loop_nodes ) ) )
loop_head_to_loop_nodes

@ -256,8 +256,7 @@ let checker {IntraproceduralAnalysis.proc_desc; err_log} =
(Typ.pp_full Pp.text) typ
in
let ltr = [Errlog.make_trace_element 0 loc "Write of unused value" []] in
let attrs = Procdesc.get_attributes proc_desc in
Reporting.log_error attrs err_log ~loc ~ltr IssueType.dead_store message
Reporting.log_error proc_desc err_log ~loc ~ltr IssueType.dead_store message
in
let report_dead_store live_vars captured_by_ref_vars = function
| Sil.Store {e1= Lvar pvar; typ; e2= rhs_exp; loc}

@ -99,7 +99,6 @@ let rec format_string_type_names (fmt_string : string) (start : int) : string li
let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr) (proc_name : Procname.t)
(proc_desc : Procdesc.t) err_log : unit =
let attrs = Procdesc.get_attributes proc_desc in
(* Check if format string lines up with arguments *)
let rec check_type_names instr_loc n_arg instr_proc_name fmt_type_names arg_type_names =
let instr_name = Procname.to_simplified_string instr_proc_name in
@ -112,7 +111,7 @@ let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr) (proc
"%s at line %s: parameter %d is expected to be of type %s but %s was given."
instr_name instr_line n_arg (default_format_type_name ft) gt
in
Reporting.log_error attrs err_log ~loc:instr_loc IssueType.checkers_printf_args
Reporting.log_error proc_desc err_log ~loc:instr_loc IssueType.checkers_printf_args
description
else check_type_names instr_loc (n_arg + 1) instr_proc_name fs gs
| [], [] ->
@ -122,7 +121,8 @@ let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr) (proc
Printf.sprintf "format string arguments don't mach provided arguments in %s at line %s"
instr_name instr_line
in
Reporting.log_error attrs err_log ~loc:instr_loc IssueType.checkers_printf_args description
Reporting.log_error proc_desc err_log ~loc:instr_loc IssueType.checkers_printf_args
description
in
(* Get the array ivar for a given nvar *)
let array_ivar instrs nvar =
@ -158,7 +158,7 @@ let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr) (proc
vararg_ivar_type_names
| None ->
if not (Reporting.is_suppressed tenv proc_desc IssueType.checkers_printf_args) then
Reporting.log_warning attrs err_log ~loc:cl IssueType.checkers_printf_args
Reporting.log_warning proc_desc err_log ~loc:cl IssueType.checkers_printf_args
"Format string must be string literal"
with e ->
L.internal_error "%s Exception when analyzing %s: %s@."

@ -201,8 +201,7 @@ let report_errors {InterproceduralAnalysis.proc_desc; err_log} astate_opt =
let loc = Procdesc.get_loc proc_desc in
let exp_desc = F.asprintf "Side-effect free function %a" Procname.pp proc_name in
let ltr = [Errlog.make_trace_element 0 loc exp_desc []] in
let attrs = Procdesc.get_attributes proc_desc in
Reporting.log_error attrs err_log ~loc ~ltr IssueType.pure_function exp_desc
Reporting.log_error proc_desc err_log ~loc ~ltr IssueType.pure_function exp_desc
| None ->
L.internal_error "Analyzer failed to compute purity information for %a@." Procname.pp
proc_name

@ -78,8 +78,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
access_expr
in
let ltr = [Errlog.make_trace_element 0 loc "" []] in
let attrs = Procdesc.get_attributes proc_desc in
Reporting.log_error attrs err_log ~loc ~ltr IssueType.uninitialized_value message
Reporting.log_error proc_desc err_log ~loc ~ltr IssueType.uninitialized_value message
let is_struct t = match t.Typ.desc with Typ.Tstruct _ -> true | _ -> false

@ -236,7 +236,7 @@ let is_report_suppressed pname =
module Check = struct
let report_threshold pname attrs err_log ~name ~location ~cost CostIssues.{expensive_issue}
let report_threshold pname proc_desc err_log ~name ~location ~cost CostIssues.{expensive_issue}
~threshold ~is_on_ui_thread =
let report_issue_type =
L.(debug Analysis Medium) "@\n\n++++++ Checking error type for %a **** @\n" Procname.pp pname ;
@ -261,16 +261,16 @@ module Check = struct
in
Errlog.make_trace_element 0 location cost_desc []
in
Reporting.log_error attrs err_log ~loc:location
Reporting.log_error proc_desc err_log ~loc:location
~ltr:(cost_trace_elem :: BasicCost.polynomial_traces cost)
~extras:(compute_errlog_extras cost) report_issue_type message
let report_top_and_unreachable pname attrs err_log loc ~name ~cost
let report_top_and_unreachable pname proc_desc err_log loc ~name ~cost
{CostIssues.unreachable_issue; infinite_issue} =
let report issue suffix =
let message = F.asprintf "%s of the function %a %s" name Procname.pp pname suffix in
Reporting.log_error attrs err_log ~loc
Reporting.log_error proc_desc err_log ~loc
~ltr:(BasicCost.polynomial_traces cost)
~extras:(compute_errlog_extras cost) issue message
in
@ -290,16 +290,12 @@ module Check = struct
| ThresholdReports.Threshold _ | ThresholdReports.NoReport ->
()
| ThresholdReports.ReportOn {location; cost} ->
report_threshold pname
(Procdesc.get_attributes proc_desc)
err_log ~name ~location ~cost kind_spec ~threshold:(Option.value_exn threshold)
~is_on_ui_thread ) ;
report_threshold pname proc_desc err_log ~name ~location ~cost kind_spec
~threshold:(Option.value_exn threshold) ~is_on_ui_thread ) ;
CostIssues.CostKindMap.iter2 CostIssues.enabled_cost_map costs
~f:(fun _kind (CostIssues.{name; top_and_unreachable} as issue_spec) cost ->
if top_and_unreachable then
report_top_and_unreachable pname
(Procdesc.get_attributes proc_desc)
err_log proc_loc ~name ~cost issue_spec ) )
report_top_and_unreachable pname proc_desc err_log proc_loc ~name ~cost issue_spec ) )
end
type bound_map = BasicCost.t Node.IdMap.t

@ -70,7 +70,7 @@ let get_hoist_inv_map tenv ~get_callee_purity reaching_defs_invariant_map loop_h
loop_head_to_source_nodes LoopHeadToHoistInstrs.empty
let do_report extract_cost_if_expensive proc_attrs err_log (Call.{pname; loc} as call) loop_head_loc
let do_report extract_cost_if_expensive proc_desc err_log (Call.{pname; loc} as call) loop_head_loc
=
let exp_desc =
F.asprintf "The call to %a at %a is loop-invariant" Procname.pp pname Location.pp loc
@ -96,7 +96,7 @@ let do_report extract_cost_if_expensive proc_attrs err_log (Call.{pname; loc} as
F.asprintf "%s%s. It can be moved out of the loop at %a." exp_desc cost_msg Location.pp
loop_head_loc
in
Reporting.log_error proc_attrs err_log ~loc ~ltr issue message
Reporting.log_error proc_desc err_log ~loc ~ltr issue message
let get_cost_if_expensive tenv integer_type_widths get_callee_cost_summary_and_formals
@ -149,9 +149,7 @@ let report_errors proc_desc tenv err_log get_callee_purity reaching_defs_invaria
(fun loop_head inv_instrs ->
let loop_head_loc = Procdesc.Node.get_loc loop_head in
HoistCalls.iter
(fun call ->
let proc_attrs = Procdesc.get_attributes proc_desc in
do_report extract_cost_if_expensive proc_attrs err_log call loop_head_loc )
(fun call -> do_report extract_cost_if_expensive proc_desc err_log call loop_head_loc)
inv_instrs )
loop_head_to_inv_instrs

@ -17,9 +17,8 @@ let report_error {IntraproceduralAnalysis.proc_desc; tenv; err_log} kind loc ?(f
let localized_description = Localise.verbatim_desc description in
let exn = exception_kind kind localized_description in
let trace = [Errlog.make_trace_element 0 loc description []] in
let attrs = Procdesc.get_attributes proc_desc in
let node = AnalysisState.get_node_exn () in
let session = AnalysisState.get_session () in
Reporting.log_issue_from_summary severity attrs err_log
Reporting.log_issue_from_summary severity proc_desc err_log
~node:(BackendNode {node})
~session ~loc ~ltr:trace exn

@ -13,9 +13,8 @@ open PulseBasicInterface
open PulseDomainInterface
let report {InterproceduralAnalysis.proc_desc; err_log} diagnostic =
let attrs = Procdesc.get_attributes proc_desc in
let open Diagnostic in
Reporting.log_error attrs err_log ~loc:(get_location diagnostic) ~ltr:(get_trace diagnostic)
Reporting.log_error proc_desc err_log ~loc:(get_location diagnostic) ~ltr:(get_trace diagnostic)
(get_issue_type diagnostic) (get_message diagnostic)

@ -298,8 +298,7 @@ module Make (TaintSpecification : TaintSpec.S) = struct
get_short_trace_string initial_source initial_source_caller final_sink final_sink_caller
in
let ltr = source_trace @ List.rev sink_trace in
let attrs = Procdesc.get_attributes proc_desc in
Reporting.log_error attrs err_log ~loc:(CallSite.loc cur_site) ~ltr issue trace_str
Reporting.log_error proc_desc err_log ~loc:(CallSite.loc cur_site) ~ltr issue trace_str
in
List.iter ~f:report_one (TraceDomain.get_reports ~cur_site trace)

@ -266,8 +266,7 @@ let add_errors env proc_desc err_log biabduction_summary =
let property, _vname = ToplAutomaton.vname (Lazy.force automaton) error in
let message = Printf.sprintf "property %s reaches error" property in
tt "WARN@\n" ;
let attrs = Procdesc.get_attributes proc_desc in
Reporting.log_error attrs err_log IssueType.topl_error ~loc message )
Reporting.log_error proc_desc err_log IssueType.topl_error ~loc message )
in
(* Don't warn if [lookup_static_var] fails. *)
Option.iter ~f:handle_state_post_value (lookup_static_var env state_var post)

Loading…
Cancel
Save