[retain cycles] Use decompiled expressions in the retain cycle message

Reviewed By: mbouaziz

Differential Revision: D7292599

fbshipit-source-id: 8e6b0ed
master
Dulma Churchill 7 years ago committed by Facebook Github Bot
parent d04a7aed52
commit aca39195f8

@ -40,6 +40,10 @@ let split_var_clang var_name =
match String.rsplit2 ~on:'.' var_name with Some (_, name) -> name | _ -> var_name match String.rsplit2 ~on:'.' var_name with Some (_, name) -> name | _ -> var_name
let builtin_functions_to_string pn =
if Typ.Procname.equal pn BuiltinDecl.__objc_alloc_no_fail then Some "alloc" else None
(** convert a dexp to a string *) (** convert a dexp to a string *)
let rec to_string = function let rec to_string = function
| Darray (de1, de2) -> | Darray (de1, de2) ->
@ -49,6 +53,10 @@ let rec to_string = function
| Dconst Cfun pn | Dconst Cfun pn
-> ( -> (
let procname_str = Typ.Procname.to_simplified_string pn in let procname_str = Typ.Procname.to_simplified_string pn in
match builtin_functions_to_string pn with
| Some str ->
str
| None ->
match pn with match pn with
| Typ.Procname.ObjC_Cpp {kind= ObjCInstanceMethod} | Typ.Procname.ObjC_Cpp {kind= ObjCInstanceMethod}
| Typ.Procname.ObjC_Cpp {kind= ObjCClassMethod} -> ( | Typ.Procname.ObjC_Cpp {kind= ObjCClassMethod} -> (

@ -18,11 +18,20 @@ let desc_retain_cycle tenv (cycle: RetainCyclesType.t) =
let index = index_ + 1 in let index = index_ + 1 in
let node = State.get_node () in let node = State.get_node () in
let from_exp_str edge_obj = let from_exp_str edge_obj =
ignore (Errdesc.find_outermost_dereference tenv node edge_obj.rc_from.rc_node_exp) ; let type_str =
(* | Some de -> MF.monospaced_to_string (Format.sprintf "%s*" (Typ.to_string edge_obj.rc_from.rc_node_typ))
DecompiledExp.to_string de in
| None -> TODO (T26707784): fix issues with DecompiledExp.to_string *) match Errdesc.find_outermost_dereference tenv node edge_obj.rc_from.rc_node_exp with
Format.sprintf "(object of type %s)" (Typ.to_string edge_obj.rc_from.rc_node_typ) | Some de
-> (
let decomp = DecompiledExp.to_string de in
match de with
| DecompiledExp.Dretcall _ ->
Format.sprintf "object %s of type %s" decomp type_str
| _ ->
Format.sprintf "%s of type %s" (MF.monospaced_to_string decomp) type_str )
| None ->
Format.sprintf "object of type %s" type_str
in in
let location_str = let location_str =
match edge with match edge with
@ -38,9 +47,8 @@ let desc_retain_cycle tenv (cycle: RetainCyclesType.t) =
let cycle_item_str = let cycle_item_str =
match edge with match edge with
| Object obj -> | Object obj ->
MF.monospaced_to_string Format.sprintf "%s --> %s" (from_exp_str obj)
(Format.sprintf "%s->%s" (from_exp_str obj) (MF.monospaced_to_string (Typ.Fieldname.to_string obj.rc_field.rc_field_name))
(Typ.Fieldname.to_string obj.rc_field.rc_field_name))
| Block (_, var) -> | Block (_, var) ->
Format.sprintf "a block that captures %s" (MF.monospaced_to_string (Pvar.to_string var)) Format.sprintf "a block that captures %s" (MF.monospaced_to_string (Pvar.to_string var))
in in

Loading…
Cancel
Save