Replace query for getter and setter with info from the procdesc rather than the property map

Summary:
public This info is based on clang's pointers so it should be more accurate. Also we want to remove the
property map.

Reviewed By: ddino

Differential Revision: D2739487

fb-gh-sync-id: 6be620a
master
Dulma Rodriguez 9 years ago committed by facebook-github-bot-1
parent 2565bb1438
commit 339cf56eb9

@ -149,8 +149,21 @@ let static_vars_for_block context block_name =
try Procname.Map.find block_name context.blocks_static_vars
with Not_found -> []
let rec get_outer_procname context =
match context.outer_context with
| Some outer_context -> get_outer_procname outer_context
| None -> Cfg.Procdesc.get_proc_name context.procdesc
let is_curr_proc_objc_getter context field_name =
let attrs = Cfg.Procdesc.get_attributes context.procdesc in
match attrs.ProcAttributes.objc_accessor with
| Some ProcAttributes.Objc_getter field ->
Ident.fieldname_equal field field_name
| _ -> false
let is_curr_proc_objc_setter context field_name =
let attrs = Cfg.Procdesc.get_attributes context.procdesc in
match attrs.ProcAttributes.objc_accessor with
| Some ProcAttributes.Objc_setter field ->
Ident.fieldname_equal field field_name
| _ -> false

@ -64,3 +64,7 @@ val static_vars_for_block : t -> Procname.t -> (Sil.pvar * Sil.typ) list
val is_objc_instance : t -> bool
val get_outer_procname : t -> Procname.t
val is_curr_proc_objc_getter : t -> Ident.fieldname -> bool
val is_curr_proc_objc_setter : t -> Ident.fieldname -> bool

@ -34,7 +34,6 @@ let checker_strong_delegate_warning class_decl_info pname ptype =
a property declared atomic should not be accessed directly via its ivar *)
let direct_atomic_property_access context stmt_info ivar_name =
let tenv = CContext.get_tenv context in
let curr_class = CContext.get_curr_class context in
let mname = Cfg.Procdesc.get_proc_name (CContext.get_procdesc context) in
let ivar, cname = match ivar_name with
| Some n ->
@ -51,7 +50,8 @@ let direct_atomic_property_access context stmt_info ivar_name =
(3) the access of the ivar is not in the init method
Last two conditions avoids false positives *)
let condition = (CField_decl.is_ivar_atomic ivar (flds1 @ flds2))
&& not (ObjcProperty_decl.is_getter_setter curr_class mname ivar_name)
&& not (CContext.is_curr_proc_objc_getter context ivar)
&& not (CContext.is_curr_proc_objc_setter context ivar)
&& not (Procname.is_constructor mname) in
let warning_desc = {
name = "DIRECT_ATOMIC_PROPERTY_ACCESS";

@ -263,15 +263,3 @@ let get_methods curr_class decl_list =
meth_name:: list_methods
| _ -> list_methods in
IList.fold_right get_method decl_list []
(* checks whether mname is a getter or setter of the ivar given in dr_name *)
let is_getter_setter curr_class mname dr_name =
match dr_name with
| Some ndi ->
(match Property.find_property_name_from_ivar curr_class ndi with
| Some pname ->
let _, _, _, (gn, _), (sn, _), _ = Property.find_property curr_class pname in
let m = Procname.to_simplified_string mname in
(m = gn) || (m = sn)
| None -> false)
| _ -> false

@ -65,7 +65,3 @@ val find_properties_class : CContext.curr_class ->
(* Given a property type returns whether the property is strong *)
val is_strong_property : property_type -> bool
(* Checks whether mname is a getter or setter of the ivar given in dr_name *)
val is_getter_setter :
CContext.curr_class -> Procname.t -> Clang_ast_t.named_decl_info option -> bool

Loading…
Cancel
Save