Split get_super into get_super_impl and get_super_if

Reviewed By: jvillard

Differential Revision: D3693879

fbshipit-source-id: b18f930
master
Ryan Rhee 9 years ago committed by Facebook Github Bot 6
parent cdce8f9794
commit 70d5b604bf

@ -334,7 +334,7 @@ let checker_NSNotificationCenter _ decl_info impl_decl_info decls =
match super with match super with
| Some (decl_list, impl_decl_info) -> | Some (decl_list, impl_decl_info) ->
(f decl_list (f decl_list
|| exists_on_hierarchy f (Ast_utils.get_super impl_decl_info)) || exists_on_hierarchy f (Ast_utils.get_super_impl impl_decl_info))
| None -> false in | None -> false in
let eventually_removeObserver_in_whole_hierarchy decls impl_decl_info = let eventually_removeObserver_in_whole_hierarchy decls impl_decl_info =

@ -469,15 +469,25 @@ struct
Buffer.add_string buffer name; Buffer.add_string buffer name;
Buffer.contents buffer Buffer.contents buffer
let get_super impl_decl_info = let rec get_super_if decl =
match decl with
| Some Clang_ast_t.ObjCImplementationDecl(_, _, _, _, impl_decl_info) ->
(* Try getting the super ref through the impl info, and fall back to
getting the if decl first and getting the super ref through it. *)
let super_ref = get_decl_opt_with_decl_ref impl_decl_info.oidi_super in
if Option.is_some super_ref then
super_ref
else
get_super_if (get_decl_opt_with_decl_ref impl_decl_info.oidi_class_interface)
| Some Clang_ast_t.ObjCInterfaceDecl(_, _, _, _, interface_decl_info) ->
get_decl_opt_with_decl_ref interface_decl_info.otdi_super
| _ -> None
let get_super_impl impl_decl_info =
let objc_interface_decl_current = let objc_interface_decl_current =
get_decl_opt_with_decl_ref get_decl_opt_with_decl_ref
impl_decl_info.Clang_ast_t.oidi_class_interface in impl_decl_info.Clang_ast_t.oidi_class_interface in
let objc_interface_decl_super = let objc_interface_decl_super = get_super_if objc_interface_decl_current in
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 = let objc_implementation_decl_super =
match objc_interface_decl_super with match objc_interface_decl_super with
| Some ObjCInterfaceDecl(_, _, _, _, interface_decl_info) -> | Some ObjCInterfaceDecl(_, _, _, _, interface_decl_info) ->

@ -159,11 +159,15 @@ sig
(* Generates a key for a declaration based on its name and the declaration tag. *) (* Generates a key for a declaration based on its name and the declaration tag. *)
val generate_key_decl : Clang_ast_t.decl -> string val generate_key_decl : Clang_ast_t.decl -> string
(* Given an objc impl or interface decl, returns the objc interface decl of
the superclass, if any. *)
val get_super_if : Clang_ast_t.decl option -> Clang_ast_t.decl option
(* (*
* Given an objc impl decl info, return the super class's list of decls and * Given an objc impl decl info, return the super class's list of decls and
* its objc impl decl info. * its objc impl decl info.
*) *)
val get_super : val get_super_impl :
Clang_ast_t.obj_c_implementation_decl_info -> Clang_ast_t.obj_c_implementation_decl_info ->
(Clang_ast_t.decl list * (Clang_ast_t.decl list *
Clang_ast_t.obj_c_implementation_decl_info) Clang_ast_t.obj_c_implementation_decl_info)

Loading…
Cancel
Save