Clean up special handling of smart pointers in backend

Summary: Smart pointers are now translated as pointers, previous heurisitcs to improve reporting shouldn't apply anymore

Reviewed By: dulmarod

Differential Revision: D3791069

fbshipit-source-id: 662e911
master
Andrzej Kotulski 8 years ago committed by Facebook Github Bot 2
parent 2444618943
commit 7461d40024

@ -123,8 +123,7 @@ type inst =
| Irearrange of zero_flag null_case_flag int PredSymb.path_pos
| Itaint
| Iupdate of zero_flag null_case_flag int PredSymb.path_pos
| Ireturn_from_call of int
| Ireturn_from_pointer_wrapper_call of int;
| Ireturn_from_call of int;
/** structured expressions represent a value of structured type, such as an array or a struct. */
@ -965,7 +964,6 @@ let inst_new_loc loc inst =>
| Itaint => inst
| Iupdate zf ncf _ pos => Iupdate zf ncf loc.Location.line pos
| Ireturn_from_call _ => Ireturn_from_call loc.Location.line
| Ireturn_from_pointer_wrapper_call _ => Ireturn_from_pointer_wrapper_call loc.Location.line
};
@ -996,7 +994,6 @@ let inst_to_string inst => {
| Iupdate zf ncf n _ =>
"update:" ^ zero_flag_to_string zf ^ null_case_flag_to_string ncf ^ string_of_int n
| Ireturn_from_call n => "return_from_call: " ^ string_of_int n
| Ireturn_from_pointer_wrapper_call n => "Ireturn_from_pointer_wrapper_call: " ^ string_of_int n
}
};
@ -1048,8 +1045,7 @@ let inst_zero_flag =
| Irearrange zf _ _ _ => zf
| Itaint => None
| Iupdate zf _ _ _ => zf
| Ireturn_from_call _
| Ireturn_from_pointer_wrapper_call _ => None;
| Ireturn_from_call _ => None;
/** Set the null case flag of the inst. */
@ -1096,7 +1092,6 @@ let update_inst inst_old inst_new => {
let zf' = combine_zero_flags (inst_zero_flag inst_old) zf;
Iupdate zf' ncf n pos
| Ireturn_from_call _ => inst_new
| Ireturn_from_pointer_wrapper_call _ => inst_new
}
};

@ -115,8 +115,7 @@ type inst =
| Irearrange of zero_flag null_case_flag int PredSymb.path_pos
| Itaint
| Iupdate of zero_flag null_case_flag int PredSymb.path_pos
| Ireturn_from_call of int
| Ireturn_from_pointer_wrapper_call of int;
| Ireturn_from_call of int;
let inst_abstraction: inst;

@ -117,8 +117,6 @@ let check_access access_opt de_opt =
find_bucket n ncf
| Some (Localise.Returned_from_call n) ->
find_bucket n false
| Some (Localise.Returned_from_pointer_wrapper_call _) ->
Some Localise.BucketLevel.b2
| Some (Localise.Last_accessed (_, is_nullable)) when is_nullable ->
Some Localise.BucketLevel.b1
| _ ->

@ -16,13 +16,6 @@ module L = Logging
module F = Format
module DExp = DecompiledExp
let smart_pointers = [
["std"; "shared_ptr"];
["std"; "unique_ptr"]
]
let pointer_wrapper_classes = smart_pointers
let vector_class = ["std"; "vector"]
let is_one_of_classes class_name classes =
@ -38,9 +31,6 @@ let is_method_of_objc_cpp_class pname classes =
is_one_of_classes class_name classes
| _ -> false
let method_of_pointer_wrapper pname =
is_method_of_objc_cpp_class pname pointer_wrapper_classes
let is_vector_method pname =
is_method_of_objc_cpp_class pname [vector_class]
@ -761,10 +751,6 @@ let explain_dexp_access prop dexp is_nullable =
| Const.Cfun _ -> (* Treat function as an update *)
Some (Sil.Eexp (Exp.Const c, Sil.Ireturn_from_call loc.Location.line))
| _ -> None)
| DExp.Dretcall (DExp.Dconst (Const.Cfun pname as c ) , _, loc, _ )
when method_of_pointer_wrapper pname ->
if verbose then (L.d_strln "lookup: found Dretcall ");
Some (Sil.Eexp (Exp.Const c, Sil.Ireturn_from_pointer_wrapper_call loc.Location.line))
| DExp.Dpvaraddr pvar ->
(L.d_strln ("lookup: found Dvaraddr " ^ DExp.to_string (DExp.Dpvaraddr pvar)));
find_ptsto (Exp.Lvar pvar)
@ -783,8 +769,6 @@ let explain_dexp_access prop dexp is_nullable =
Some (Localise.Last_accessed (n, is_nullable))
| Some (Sil.Ireturn_from_call n) ->
Some (Localise.Returned_from_call n)
| Some (Sil.Ireturn_from_pointer_wrapper_call n) ->
Some (Localise.Returned_from_pointer_wrapper_call n)
| Some Sil.Ialloc when !Config.curr_language = Config.Java ->
Some Localise.Initialized_automatically
| Some inst ->
@ -817,10 +801,6 @@ let explain_dereference_access outermost_array is_nullable _de_opt prop =
| Some de ->
Some (if outermost_array then remove_outermost_array_access de else de) in
let value_str = match de_opt with
| Some (DExp.Darrow ((DExp.Dpvaraddr pvar), f) as de) ->
if is_special_field smart_pointers None f then
DExp.to_string (DExp.Dpvaraddr pvar)
else DExp.to_string de
| Some de ->
DExp.to_string de
| None -> "" in

@ -481,7 +481,6 @@ type access =
| Last_accessed of int * bool (* line, is_nullable flag *)
| Initialized_automatically
| Returned_from_call of int
| Returned_from_pointer_wrapper_call of int
let dereference_string deref_str value_str access_opt loc =
let tags = deref_str.tags in
@ -507,7 +506,6 @@ let dereference_string deref_str value_str access_opt loc =
Tags.add tags Tags.assigned_line line_str;
["last assigned on line " ^ line_str]
| Some (Returned_from_call _) -> []
| Some (Returned_from_pointer_wrapper_call _) -> []
| Some Initialized_automatically ->
["initialized automatically"] in
let problem_desc =

@ -176,7 +176,6 @@ type access =
| Last_accessed of int * bool (* line, is_nullable flag *)
| Initialized_automatically
| Returned_from_call of int
| Returned_from_pointer_wrapper_call of int
val dereference_string : deref_str -> string -> access option -> Location.t -> error_desc

Loading…
Cancel
Save