From 14c616e34fa8c42fd8955b3088aaba0fb807f0e6 Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Mon, 23 Nov 2015 10:40:31 -0800 Subject: [PATCH] clean up some duplicate code in Errdesc Reviewed By: jeremydubreil Differential Revision: D2670354 fb-gh-sync-id: d5e664f --- infer/src/backend/errdesc.ml | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/infer/src/backend/errdesc.ml b/infer/src/backend/errdesc.ml index a54370d35..0bb3e450d 100644 --- a/infer/src/backend/errdesc.ml +++ b/infer/src/backend/errdesc.ml @@ -14,9 +14,6 @@ module L = Logging module F = Format open Utils -let pvar_to_string pvar = - Mangled.to_string (Sil.pvar_get_name pvar) - (** Check whether the hpred is a |-> representing a resource in the Racquire state *) let hpred_is_open_resource prop = function | Sil.Hpointsto(e, _, _) -> @@ -32,7 +29,7 @@ let explain_context_leak pname context_typ fieldname error_path = (** Explain a deallocate stack variable error *) let explain_deallocate_stack_var pvar ra = - let pvar_str = pvar_to_string pvar in + let pvar_str = Sil.pvar_to_string pvar in Localise.desc_deallocate_stack_variable pvar_str ra.Sil.ra_pname ra.Sil.ra_loc (** Explain a deallocate constant string error *) @@ -186,19 +183,19 @@ let rec find_boolean_assignment node pvar true_branch : Cfg.Node.t option = (** Check whether the program variable is a temporary one generated by CIL *) let pvar_is_cil_tmp pvar = Sil.pvar_is_local pvar && - let name = pvar_to_string pvar in + let name = Sil.pvar_to_string pvar in string_is_prefix "_tmp" name (** Check whether the program variable is a temporary one generated by EDG *) let pvar_is_edg_tmp pvar = Sil.pvar_is_local pvar && - let name = pvar_to_string pvar in + let name = Sil.pvar_to_string pvar in string_is_prefix "__T" name (** Check whether the program variable is a temporary one generated by sawja *) let pvar_is_sawja_tmp pvar = Sil.pvar_is_local pvar && - let name = pvar_to_string pvar in + let name = Sil.pvar_to_string pvar in string_is_prefix "$irvar" name || string_is_prefix "$T" name || string_is_prefix "$bc" name @@ -208,7 +205,7 @@ let edg_native_tmp_var_name_prefix = "__temp_var_" (** Check whether the program variable is a temporary one generated by EDG *) let pvar_is_edg_tmp pvar = Sil.pvar_is_local pvar && - let name = pvar_to_string pvar in + let name = Sil.pvar_to_string pvar in string_is_prefix edg_native_tmp_var_name_prefix name (** Check whether the program variable is a temporary generated by the front-end *) @@ -276,11 +273,7 @@ and _exp_lv_dexp (_seen : Sil.ExpSet.t) node e : Sil.dexp option = if pvar_is_frontend_tmp pvar then begin match find_program_variable_assignment node pvar with - | None -> - (* - L.err "exp_string_lv: Cannot find assignment of %s@." (pvar_to_string pvar); - exit(1) *) - None + | None -> None | Some (node', id) -> begin match find_normal_variable_funcall node' id with @@ -924,7 +917,7 @@ let explain_dereference_as_caller_expression find 1 formal_params in match find_pvar_with_exp spec_pre exp with | Some (pv, pvar_off) -> - if !verbose then L.d_strln ("pvar: " ^ (pvar_to_string pv)); + if !verbose then L.d_strln ("pvar: " ^ (Sil.pvar_to_string pv)); let pv_name = Sil.pvar_get_name pv in if Sil.pvar_is_global pv then @@ -936,7 +929,7 @@ let explain_dereference_as_caller_expression explain_nth_function_parameter use_buckets deref_str actual_pre position pvar_off else if Prop.has_dangling_uninit_attribute spec_pre exp then - Localise.desc_uninitialized_dangling_pointer_deref deref_str (pvar_to_string pv) loc + Localise.desc_uninitialized_dangling_pointer_deref deref_str (Sil.pvar_to_string pv) loc else Localise.no_desc | None -> if !verbose then (L.d_str "explain_dereference_as_caller_expression "; Sil.d_exp exp; L.d_str ": cannot explain None "; L.d_ln ()); @@ -1013,7 +1006,7 @@ let explain_stack_variable_address_escape loc pvar addr_dexp_opt = Some "the caller via a return" | Some dexp -> Some (Sil.dexp_to_string dexp) | None -> None in - Localise.desc_stack_variable_address_escape (pvar_to_string pvar) addr_dexp_str loc + Localise.desc_stack_variable_address_escape (Sil.pvar_to_string pvar) addr_dexp_str loc (** explain unary minus applied to unsigned expression *) let explain_unary_minus_applied_to_unsigned_expression exp typ node loc =