[clang][frontend] Type ptr to objc if function

Reviewed By: dulmarod

Differential Revision: D3940841

fbshipit-source-id: 0495e15
master
Ryan Rhee 8 years ago committed by Facebook Github Bot
parent 8f731569fc
commit 609d1f9058

@ -115,21 +115,12 @@ let component_factory_function_advice context decl =
let is_component_if decl = let is_component_if decl =
Ast_utils.is_objc_if_descendant decl [CFrontend_config.ckcomponent_cl] in Ast_utils.is_objc_if_descendant decl [CFrontend_config.ckcomponent_cl] in
let rec type_ptr_to_objc_if type_ptr =
let typ_opt = Ast_utils.get_desugared_type type_ptr in
match (typ_opt : Clang_ast_t.c_type option) with
| Some ObjCInterfaceType (_, decl_ptr) -> Ast_utils.get_decl decl_ptr
| Some ObjCObjectPointerType (_, (inner_qual_type: Clang_ast_t.qual_type)) ->
type_ptr_to_objc_if inner_qual_type.qt_type_ptr
| Some FunctionProtoType (_, function_type_info, _)
| Some FunctionNoProtoType (_, function_type_info) ->
type_ptr_to_objc_if function_type_info.Clang_ast_t.fti_return_type
| _ -> None in
match decl with match decl with
| Clang_ast_t.FunctionDecl (decl_info, _, (qual_type: Clang_ast_t.qual_type), _) -> | Clang_ast_t.FunctionDecl (decl_info, _, (qual_type: Clang_ast_t.qual_type), _) ->
let condition = is_ck_context context decl let objc_interface =
&& is_component_if (type_ptr_to_objc_if qual_type.qt_type_ptr) in Ast_utils.type_ptr_to_objc_interface qual_type.qt_type_ptr in
let condition =
is_ck_context context decl && is_component_if objc_interface in
if condition then if condition then
Some { Some {
CIssue.issue = CIssue.Component_factory_function; CIssue.issue = CIssue.Component_factory_function;

@ -460,6 +460,17 @@ struct
|| is_objc_if_descendant ~blacklist:blacklist (get_super_if if_decl) ancestors) || is_objc_if_descendant ~blacklist:blacklist (get_super_if if_decl) ancestors)
| _ -> false | _ -> false
let rec type_ptr_to_objc_interface type_ptr =
let typ_opt = get_desugared_type type_ptr in
match (typ_opt : Clang_ast_t.c_type option) with
| Some ObjCInterfaceType (_, decl_ptr) -> get_decl decl_ptr
| Some ObjCObjectPointerType (_, (inner_qual_type: Clang_ast_t.qual_type)) ->
type_ptr_to_objc_interface inner_qual_type.qt_type_ptr
| Some FunctionProtoType (_, function_type_info, _)
| Some FunctionNoProtoType (_, function_type_info) ->
type_ptr_to_objc_interface function_type_info.Clang_ast_t.fti_return_type
| _ -> None
(* (*
let rec getter_attribute_opt attributes = let rec getter_attribute_opt attributes =
match attributes with match attributes with

@ -171,6 +171,7 @@ sig
val is_objc_if_descendant : val is_objc_if_descendant :
?blacklist:string list -> Clang_ast_t.decl option -> string list -> bool ?blacklist:string list -> Clang_ast_t.decl option -> string list -> bool
val type_ptr_to_objc_interface : Clang_ast_types.t_ptr -> Clang_ast_t.decl option
end end
module General_utils : module General_utils :

Loading…
Cancel
Save