Making the checker not report on init methods

Reviewed By: dulmarod

Differential Revision: D2723281

fb-gh-sync-id: 0c950ab
master
Dino Distefano 9 years ago committed by facebook-github-bot-1
parent e76939b53b
commit dd5b3dfd83

@ -356,7 +356,8 @@ let java_is_vararg = function
(** [is_constructor pname] returns true if [pname] is a constructor *)
let is_constructor = function
| JAVA js -> js.methodname = "<init>"
| C_METHOD name -> Utils.string_is_prefix "init" name.method_name
| C_METHOD name ->
(name.method_name = "new") || Utils.string_is_prefix "init" name.method_name
| _ -> false
let java_is_close = function

@ -47,10 +47,12 @@ let direct_atomic_property_access context stmt_info ivar_name =
| Some Sil.Tstruct (flds1, flds2, _, _, _, _, _) ->
(* We give the warning when:
(1) the property has the atomic attribute and
(2) the access of the ivar is not in a getter or setter method. This condition
avoids false positives *)
(2) the access of the ivar is not in a getter or setter method.
(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) in
&& not (ObjcProperty_decl.is_getter_setter curr_class mname ivar_name)
&& not (Procname.is_constructor mname) in
let warning_desc = {
name = "DIRECT_ATOMIC_PROPERTY_ACCESS";
description = "Direct access to ivar " ^ (Ident.fieldname_to_string ivar) ^

@ -44,6 +44,34 @@
@synthesize b;
- (A*) init
{
_p = 0; // Good access
_q = 0; // Good access
_f = 0; // Good access
}
- (A*) new
{
_p = 0; // Good access
_q = 0; // Good access
_f = 0; // Good access
}
- (A*) initWithBla: (int) d
{
_p = d; // Good access
_q = d; // Good access
_f = d; // Good access
}
- (A*) initWith: (int) e
{
_p = e; // Good access
_q = e; // Good access
_f = e; // Good access
}
- (void) writeP: (int)i
{
_p = i; // Good access

Loading…
Cancel
Save