diff --git a/infer/src/clang/predicates.ml b/infer/src/clang/predicates.ml index b9a312404..829a9b381 100644 --- a/infer/src/clang/predicates.ml +++ b/infer/src/clang/predicates.ml @@ -105,13 +105,14 @@ let is_assign_property decl = | _ -> false let is_property_pointer_type decl = + let open Clang_ast_t in match decl with - | Clang_ast_t.ObjCPropertyDecl (_, _, pdi) -> - let type_ptr = pdi.opdi_type_ptr in - let raw_ptr = Clang_ast_types.type_ptr_to_clang_pointer type_ptr in - (match Clang_ast_main.PointerMap.find raw_ptr !CFrontend_config.pointer_type_index with - | MemberPointerType _ | ObjCObjectPointerType _ | BlockPointerType _ -> true - | TypedefType (_, tti) -> + | ObjCPropertyDecl (_, _, pdi) -> + (match Ast_utils.get_desugared_type pdi.opdi_type_ptr with + | Some MemberPointerType _ + | Some ObjCObjectPointerType _ + | Some BlockPointerType _ -> true + | Some TypedefType (_, tti) -> (Ast_utils.name_of_typedef_type_info tti) = CFrontend_config.id_cl | exception Not_found -> false | _ -> false) diff --git a/infer/tests/codetoanalyze/objc/linters/assign_pointer.m b/infer/tests/codetoanalyze/objc/linters/assign_pointer.m index 53f600fdb..9c90df4c8 100644 --- a/infer/tests/codetoanalyze/objc/linters/assign_pointer.m +++ b/infer/tests/codetoanalyze/objc/linters/assign_pointer.m @@ -35,4 +35,6 @@ struct MyStruct { @property(assign) struct MyStruct* shouldNotReport7; +@property(nonatomic, assign, nullable) NSNumber* shouldReport8; + @end diff --git a/infer/tests/codetoanalyze/objc/linters/issues.exp b/infer/tests/codetoanalyze/objc/linters/issues.exp index a1b7a785b..1327e76a6 100644 --- a/infer/tests/codetoanalyze/objc/linters/issues.exp +++ b/infer/tests/codetoanalyze/objc/linters/issues.exp @@ -1,6 +1,7 @@ assign_pointer.m, Linters_dummy_method, 18, ASSIGN_POINTER_WARNING assign_pointer.m, Linters_dummy_method, 20, ASSIGN_POINTER_WARNING assign_pointer.m, Linters_dummy_method, 22, ASSIGN_POINTER_WARNING +assign_pointer.m, Linters_dummy_method, 38, ASSIGN_POINTER_WARNING atomic_prop.m, A_bla, 98, DIRECT_ATOMIC_PROPERTY_ACCESS atomic_prop.m, A_bla, 99, DIRECT_ATOMIC_PROPERTY_ACCESS atomic_prop.m, A_readP, 77, DIRECT_ATOMIC_PROPERTY_ACCESS