Direct property access should not fire on dealloc methods

Reviewed By: dulmarod

Differential Revision: D2831142

fb-gh-sync-id: f253d7f
master
Dino Distefano 9 years ago committed by facebook-github-bot-1
parent c88ac54613
commit 377893637a

@ -373,6 +373,11 @@ let is_constructor = function
(name.method_name = "new") || Utils.string_is_prefix "init" name.method_name (name.method_name = "new") || Utils.string_is_prefix "init" name.method_name
| _ -> false | _ -> false
(** [is_objc_dealloc pname] returns true if [pname] is the dealloc method in Objective-C *)
let is_objc_dealloc = function
| ObjC_Cpp_method name -> name.method_name = "dealloc"
| _ -> false
let java_is_close = function let java_is_close = function
| Java_method js -> js.method_name = "close" | Java_method js -> js.method_name = "close"
| _ -> false | _ -> false

@ -119,6 +119,9 @@ val is_anonymous_inner_class_name : string -> bool
(** [is_constructor pname] returns true if [pname] is a constructor *) (** [is_constructor pname] returns true if [pname] is a constructor *)
val is_constructor : t -> bool val is_constructor : t -> bool
(** [is_objc_dealloc pname] returns true if [pname] is the dealloc method in Objective-C *)
val is_objc_dealloc : t -> bool
(** [java_is_close pname] returns true if the method name is "close" *) (** [java_is_close pname] returns true if the method name is "close" *)
val java_is_close : t -> bool val java_is_close : t -> bool

@ -52,7 +52,8 @@ let direct_atomic_property_access context stmt_info ivar_name =
let condition = (CField_decl.is_ivar_atomic ivar (flds1 @ flds2)) let condition = (CField_decl.is_ivar_atomic ivar (flds1 @ flds2))
&& not (CContext.is_curr_proc_objc_getter context ivar) && not (CContext.is_curr_proc_objc_getter context ivar)
&& not (CContext.is_curr_proc_objc_setter context ivar) && not (CContext.is_curr_proc_objc_setter context ivar)
&& not (Procname.is_constructor mname) in && not (Procname.is_constructor mname)
&& not (Procname.is_objc_dealloc mname) in
let warning_desc = { let warning_desc = {
name = "DIRECT_ATOMIC_PROPERTY_ACCESS"; name = "DIRECT_ATOMIC_PROPERTY_ACCESS";
description = "Direct access to ivar " ^ (Ident.fieldname_to_string ivar) ^ description = "Direct access to ivar " ^ (Ident.fieldname_to_string ivar) ^

@ -72,6 +72,11 @@
_f = e; // Good access _f = e; // Good access
} }
- (void) dealloc
{
_q = 0; // Good access
}
- (void) writeP: (int)i - (void) writeP: (int)i
{ {
_p = i; // Good access _p = i; // Good access

Loading…
Cancel
Save