diff --git a/infer/src/clang/cFrontend_checkers.ml b/infer/src/clang/cFrontend_checkers.ml index 152e20487..2232b2607 100644 --- a/infer/src/clang/cFrontend_checkers.ml +++ b/infer/src/clang/cFrontend_checkers.ml @@ -330,30 +330,11 @@ let checker_NSNotificationCenter _ decl_info impl_decl_info decls = "removeObserver:name:object:") decls in exists_method_calling_removeObserver || exists_method_calling_removeObserverName in - let get_super impl_decl_info = - let objc_interface_decl_current = - CFrontend_utils.Ast_utils.get_decl_opt_with_decl_ref - impl_decl_info.Clang_ast_t.oidi_class_interface in - let objc_interface_decl_super = - match objc_interface_decl_current with - | Some Clang_ast_t.ObjCInterfaceDecl(_, _, _, _, interface_decl_info) -> - CFrontend_utils.Ast_utils.get_decl_opt_with_decl_ref interface_decl_info.otdi_super - | _ -> None in - let objc_implementation_decl_super = - match objc_interface_decl_super with - | Some ObjCInterfaceDecl(_, _, _, _, interface_decl_info) -> - CFrontend_utils.Ast_utils.get_decl_opt_with_decl_ref - interface_decl_info.otdi_implementation - | _ -> None in - match objc_implementation_decl_super with - | Some ObjCImplementationDecl(_, _, decl_list, _, impl_decl_info) -> - Some (decl_list, impl_decl_info) - | _ -> None in - let rec exists_on_hierarchy f super = match super with | Some (decl_list, impl_decl_info) -> - f decl_list || exists_on_hierarchy f (get_super impl_decl_info) + (f decl_list + || exists_on_hierarchy f (Ast_utils.get_super impl_decl_info)) | None -> false in let eventually_removeObserver_in_whole_hierarchy decls impl_decl_info = diff --git a/infer/src/clang/cFrontend_utils.ml b/infer/src/clang/cFrontend_utils.ml index 1947710a7..e051d06ad 100644 --- a/infer/src/clang/cFrontend_utils.ml +++ b/infer/src/clang/cFrontend_utils.ml @@ -469,6 +469,26 @@ struct Buffer.add_string buffer name; Buffer.contents buffer + let get_super impl_decl_info = + let objc_interface_decl_current = + get_decl_opt_with_decl_ref + impl_decl_info.Clang_ast_t.oidi_class_interface in + let objc_interface_decl_super = + match objc_interface_decl_current with + | Some Clang_ast_t.ObjCInterfaceDecl(_, _, _, _, interface_decl_info) -> + get_decl_opt_with_decl_ref interface_decl_info.otdi_super + | _ -> None in + let objc_implementation_decl_super = + match objc_interface_decl_super with + | Some ObjCInterfaceDecl(_, _, _, _, interface_decl_info) -> + get_decl_opt_with_decl_ref + interface_decl_info.otdi_implementation + | _ -> None in + match objc_implementation_decl_super with + | Some ObjCImplementationDecl(_, _, decl_list, _, impl_decl_info) -> + Some (decl_list, impl_decl_info) + | _ -> None + (* let rec getter_attribute_opt attributes = match attributes with @@ -486,6 +506,7 @@ struct | `Setter setter -> setter.Clang_ast_t.dr_name | _ -> (setter_attribute_opt rest) *) + end (* Global counter for anonymous block*) diff --git a/infer/src/clang/cFrontend_utils.mli b/infer/src/clang/cFrontend_utils.mli index a532f3605..afb469f59 100644 --- a/infer/src/clang/cFrontend_utils.mli +++ b/infer/src/clang/cFrontend_utils.mli @@ -159,6 +159,15 @@ sig (* Generates a key for a declaration based on its name and the declaration tag. *) val generate_key_decl : Clang_ast_t.decl -> string + (* + * Given an objc impl decl info, return the super class's list of decls and + * its objc impl decl info. + *) + val get_super : + Clang_ast_t.obj_c_implementation_decl_info -> + (Clang_ast_t.decl list * + Clang_ast_t.obj_c_implementation_decl_info) + option end