eliminate tmp vars in resource leak error message

Reviewed By: dulmarod

Differential Revision: D3551198

fbshipit-source-id: 2758f56
master
Sam Blackshear 8 years ago committed by Facebook Github Bot 3
parent f313cf2a82
commit 15534be574

@ -987,6 +987,23 @@ let const_kind_equal c1 c2 => {
const_kind_number c1 == const_kind_number c2
};
let rec dexp_has_tmp_var =
fun
| Dpvar pvar
| Dpvaraddr pvar => Pvar.is_frontend_tmp pvar
| Dderef dexp
| Ddot dexp _
| Darrow dexp _
| Dunop _ dexp
| Dsizeof _ (Some dexp) _ => dexp_has_tmp_var dexp
| Darray dexp1 dexp2
| Dbinop _ dexp1 dexp2 => dexp_has_tmp_var dexp1 || dexp_has_tmp_var dexp2
| Dretcall dexp dexp_list _ _
| Dfcall dexp dexp_list _ _ => dexp_has_tmp_var dexp || IList.exists dexp_has_tmp_var dexp_list
| Dconst _
| Dunknown
| Dsizeof _ None _ => false;
let rec attribute_compare (att1: attribute) (att2: attribute) :int =>
switch (att1, att2) {
| (Aresource ra1, Aresource ra2) =>

@ -511,6 +511,10 @@ let binop_invert: binop => exp => exp => exp;
The return value false means "don't know". */
let binop_is_zero_runit: binop => bool;
/** return true if [dexp] contains a temporary pvar */
let dexp_has_tmp_var: dexp => bool;
let mem_kind_compare: mem_kind => mem_kind => int;
let attribute_compare: attribute => attribute => int;

@ -507,9 +507,9 @@ let explain_leak tenv hpred prop alloc_att_opt bucket =
Some desc_string
end
else match vpath with
| Some de ->
| Some de when not (Sil.dexp_has_tmp_var de) ->
Some (Sil.dexp_to_string de)
| None -> None in
| _ -> None in
let res_action_opt, resource_opt, vpath = match alloc_att_opt with
| Some (Sil.Aresource ({ Sil.ra_kind = Sil.Racquire } as ra)) ->
Some ra, Some ra.Sil.ra_res, ra.Sil.ra_vpath
@ -541,8 +541,8 @@ let explain_leak tenv hpred prop alloc_att_opt bucket =
(L.d_str "explain_leak: current instruction is Nullify for pvar ";
Pvar.d pvar; L.d_ln ());
(match exp_lv_dexp (State.get_node ()) (Sil.Lvar pvar) with
| None -> None
| Some de -> Some (Sil.dexp_to_string de))
| Some de when not (Sil.dexp_has_tmp_var de)-> Some (Sil.dexp_to_string de)
| _ -> None)
| Some (Sil.Abstract _) ->
if verbose then (L.d_str "explain_leak: current instruction is Abstract"; L.d_ln ());
let get_nullify = function
@ -563,8 +563,8 @@ let explain_leak tenv hpred prop alloc_att_opt bucket =
(L.d_str "explain_leak: current instruction Set for ";
Sil.d_exp lexp; L.d_ln ());
(match exp_lv_dexp node lexp with
| Some dexp -> Some (Sil.dexp_to_string dexp)
| None -> None)
| Some dexp when not (Sil.dexp_has_tmp_var dexp) -> Some (Sil.dexp_to_string dexp)
| _ -> None)
| Some instr ->
if verbose
then

Loading…
Cancel
Save