[liveness] print type of unused var

Reviewed By: jeremydubreil

Differential Revision: D6539887

fbshipit-source-id: 9e819b0
master
Sam Blackshear 7 years ago committed by Facebook Github Bot
parent 41129087e4
commit b23e967f1b

@ -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
|| is_scope_guard typ || Procdesc.has_modify_in_block_attr proc_desc pvar )
in
let log_report pvar loc =
let log_report pvar typ loc =
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 exn = Exceptions.Checkers (issue_id, Localise.verbatim_desc message) in
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
| Sil.Store (Lvar pvar, typ, rhs_exp, loc)
when should_report pvar typ live_vars && not (is_sentinel_exp rhs_exp) ->
log_report pvar loc
log_report pvar typ loc
| Sil.Call
(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 ->
log_report pvar loc
log_report pvar typ loc
| _ ->
()
in

Loading…
Cancel
Save