@ -14,7 +14,7 @@ open General_utils
(* === Warnings on properties === *)
(* === Warnings on properties === *)
(* Strong Delegate Warning: a property with name delegate should not be declared strong *)
(* Strong Delegate Warning: a property with name delegate should not be declared strong *)
let checker_strong_delegate_warning pname ptype =
let checker_strong_delegate_warning class_decl_info pname ptype =
Printing . log_out " Checking for STRONG_DELEGATE property warning \n " ;
Printing . log_out " Checking for STRONG_DELEGATE property warning \n " ;
let delegate_regexp = Str . regexp_string_case_fold " delegate " in
let delegate_regexp = Str . regexp_string_case_fold " delegate " in
let pname_contains_delegate = try
let pname_contains_delegate = try
@ -22,11 +22,12 @@ let checker_strong_delegate_warning pname ptype =
with Not_found -> false in
with Not_found -> false in
let condition = pname_contains_delegate
let condition = pname_contains_delegate
&& ObjcProperty_decl . is_strong_property ptype in
&& ObjcProperty_decl . is_strong_property ptype in
let warning_desc = { name = " STRONG_DELEGATE_WARNING " ;
let warning_desc =
description = " Property or ivar " ^ pname . Clang_ast_t . ni_name ^ " declared strong " ;
{ name = " STRONG_DELEGATE_WARNING " ;
suggestion = " In general delegates should be declared weak or assign " ;
description = " Property or ivar " ^ pname . Clang_ast_t . ni_name ^ " declared strong " ;
loc = string_of_int ( ObjcProperty_decl . property_line ptype ) ;
suggestion = " In general delegates should be declared weak or assign " ;
} in
loc = CLocation . get_sil_location_from_range class_decl_info . Clang_ast_t . di_source_range true ;
} in
( condition , warning_desc )
( condition , warning_desc )
(* Direct Atomic Property access:
(* Direct Atomic Property access:
@ -41,9 +42,7 @@ let direct_atomic_property_access context stmt_info ivar_name =
Ast_utils . get_class_name_from_member n
Ast_utils . get_class_name_from_member n
| _ -> Ident . create_fieldname ( Mangled . from_string " " ) 0 , " " in
| _ -> Ident . create_fieldname ( Mangled . from_string " " ) 0 , " " in
let tname = Sil . TN_csu ( Sil . Class , Mangled . from_string cname ) in
let tname = Sil . TN_csu ( Sil . Class , Mangled . from_string cname ) in
let line = match ( fst stmt_info . Clang_ast_t . si_source_range ) . Clang_ast_t . sl_line with
let loc = CLocation . get_sil_location_from_range stmt_info . Clang_ast_t . si_source_range true in
| Some l -> string_of_int l
| _ -> " -1 " in
match Sil . tenv_lookup tenv tname with
match Sil . tenv_lookup tenv tname with
| Some Sil . Tstruct ( flds1 , flds2 , _ , _ , _ , _ , _ ) ->
| Some Sil . Tstruct ( flds1 , flds2 , _ , _ , _ , _ , _ ) ->
(* We give the warning when:
(* We give the warning when:
@ -57,7 +56,7 @@ let direct_atomic_property_access context stmt_info ivar_name =
description = " Direct access to ivar " ^ ( Ident . fieldname_to_string ivar ) ^
description = " Direct access to ivar " ^ ( Ident . fieldname_to_string ivar ) ^
" of an atomic property " ;
" of an atomic property " ;
suggestion = " Accessing an ivar of an atomic property makes the property nonatomic " ;
suggestion = " Accessing an ivar of an atomic property makes the property nonatomic " ;
loc = l ine ;
loc = l oc ;
} in
} in
( condition , Some warning_desc )
( condition , Some warning_desc )
| _ -> ( false , None ) (* No warning *)
| _ -> ( false , None ) (* No warning *)