|
|
@ -146,9 +146,12 @@ let checker {Callbacks.tenv; summary; proc_desc} : Specs.summary =
|
|
|
|
|| Domain.mem (Var.of_pvar pvar) live_vars || Procdesc.is_captured_var proc_desc pvar
|
|
|
|
|| Domain.mem (Var.of_pvar pvar) live_vars || Procdesc.is_captured_var proc_desc pvar
|
|
|
|
|| is_scope_guard typ || Procdesc.has_modify_in_block_attr proc_desc pvar )
|
|
|
|
|| is_scope_guard typ || Procdesc.has_modify_in_block_attr proc_desc pvar )
|
|
|
|
in
|
|
|
|
in
|
|
|
|
let log_report pvar loc =
|
|
|
|
let log_report pvar typ loc =
|
|
|
|
let issue_id = IssueType.dead_store.unique_id in
|
|
|
|
let issue_id = IssueType.dead_store.unique_id in
|
|
|
|
let message = F.asprintf "The value written to %a is never used" (Pvar.pp Pp.text) pvar in
|
|
|
|
let message =
|
|
|
|
|
|
|
|
F.asprintf "The value written to %a (type %a) is never used" (Pvar.pp Pp.text) pvar
|
|
|
|
|
|
|
|
(Typ.pp_full Pp.text) typ
|
|
|
|
|
|
|
|
in
|
|
|
|
let ltr = [Errlog.make_trace_element 0 loc "Write of unused value" []] in
|
|
|
|
let ltr = [Errlog.make_trace_element 0 loc "Write of unused value" []] in
|
|
|
|
let exn = Exceptions.Checkers (issue_id, Localise.verbatim_desc message) in
|
|
|
|
let exn = Exceptions.Checkers (issue_id, Localise.verbatim_desc message) in
|
|
|
|
Reporting.log_error summary ~loc ~ltr exn
|
|
|
|
Reporting.log_error summary ~loc ~ltr exn
|
|
|
@ -156,11 +159,11 @@ let checker {Callbacks.tenv; summary; proc_desc} : Specs.summary =
|
|
|
|
let report_dead_store live_vars = function
|
|
|
|
let report_dead_store live_vars = function
|
|
|
|
| Sil.Store (Lvar pvar, typ, rhs_exp, loc)
|
|
|
|
| Sil.Store (Lvar pvar, typ, rhs_exp, loc)
|
|
|
|
when should_report pvar typ live_vars && not (is_sentinel_exp rhs_exp) ->
|
|
|
|
when should_report pvar typ live_vars && not (is_sentinel_exp rhs_exp) ->
|
|
|
|
log_report pvar loc
|
|
|
|
log_report pvar typ loc
|
|
|
|
| Sil.Call
|
|
|
|
| Sil.Call
|
|
|
|
(None, Exp.Const Cfun (Typ.Procname.ObjC_Cpp _ as pname), (Exp.Lvar pvar, typ) :: _, loc, _)
|
|
|
|
(None, Exp.Const Cfun (Typ.Procname.ObjC_Cpp _ as pname), (Exp.Lvar pvar, typ) :: _, loc, _)
|
|
|
|
when Typ.Procname.is_constructor pname && should_report pvar typ live_vars ->
|
|
|
|
when Typ.Procname.is_constructor pname && should_report pvar typ live_vars ->
|
|
|
|
log_report pvar loc
|
|
|
|
log_report pvar typ loc
|
|
|
|
| _ ->
|
|
|
|
| _ ->
|
|
|
|
()
|
|
|
|
()
|
|
|
|
in
|
|
|
|
in
|
|
|
|