[GraphQL] Detect deprecated API usage

Reviewed By: dulmarod

Differential Revision: D4602990

fbshipit-source-id: 216de00
master
Ryan Rhee 8 years ago committed by Facebook Github Bot
parent c7abd82d44
commit 91aad00e3c

@ -418,6 +418,8 @@ let rec is_objc_if_descendant ?(blacklist = default_blacklist) if_decl ancestors
let rec type_ptr_to_objc_interface type_ptr = let rec type_ptr_to_objc_interface type_ptr =
let typ_opt = get_desugared_type type_ptr in let typ_opt = get_desugared_type type_ptr in
ctype_to_objc_interface typ_opt
and ctype_to_objc_interface typ_opt =
match (typ_opt : Clang_ast_t.c_type option) with match (typ_opt : Clang_ast_t.c_type option) with
| Some ObjCInterfaceType (_, decl_ptr) -> get_decl decl_ptr | Some ObjCInterfaceType (_, decl_ptr) -> get_decl decl_ptr
| Some ObjCObjectPointerType (_, (inner_qual_type: Clang_ast_t.qual_type)) -> | Some ObjCObjectPointerType (_, (inner_qual_type: Clang_ast_t.qual_type)) ->
@ -427,6 +429,20 @@ let rec type_ptr_to_objc_interface type_ptr =
type_ptr_to_objc_interface function_type_info.Clang_ast_t.fti_return_type type_ptr_to_objc_interface function_type_info.Clang_ast_t.fti_return_type
| _ -> None | _ -> None
let type_ptr_is_typedef_named type_ptr (type_name: string): bool =
let is_decl_name_match decl_opt =
let tuple_opt = match decl_opt with
| Some decl -> Clang_ast_proj.get_named_decl_tuple decl
| _ -> None in
match tuple_opt with
| Some (_, ni) ->
String.equal type_name ni.ni_name
| _ -> false in
match get_type type_ptr with
| Some TypedefType (_, tti) ->
let decl_opt = get_decl tti.tti_decl_ptr in
is_decl_name_match decl_opt
| _ -> false
let if_decl_to_di_pointer_opt if_decl = let if_decl_to_di_pointer_opt if_decl =
match if_decl with match if_decl with

@ -160,6 +160,8 @@ val is_objc_if_descendant :
val type_ptr_to_objc_interface : Clang_ast_types.t_ptr -> Clang_ast_t.decl option val type_ptr_to_objc_interface : Clang_ast_types.t_ptr -> Clang_ast_t.decl option
val type_ptr_is_typedef_named : Clang_ast_types.t_ptr -> string -> bool
(** A class method that returns an instance of the class is a factory method. *) (** A class method that returns an instance of the class is a factory method. *)
val is_objc_factory_method : Clang_ast_t.decl -> Clang_ast_t.decl -> bool val is_objc_factory_method : Clang_ast_t.decl -> Clang_ast_t.decl -> bool

@ -30,7 +30,8 @@ let decl_checkers_list =
(* List of checkers on stmts *that return 0 or 1 issue* *) (* List of checkers on stmts *that return 0 or 1 issue* *)
let stmt_single_checkers_list = let stmt_single_checkers_list =
[ComponentKit.component_file_cyclomatic_complexity_info; [ComponentKit.component_file_cyclomatic_complexity_info;
ComponentKit.component_initializer_with_side_effects_advice;] ComponentKit.component_initializer_with_side_effects_advice;
GraphQL.DeprecatedAPIUsage.checker;]
let stmt_checkers_list = IList.map single_to_multi stmt_single_checkers_list let stmt_checkers_list = IList.map single_to_multi stmt_single_checkers_list

@ -0,0 +1,12 @@
(*
* Copyright (c) 2016 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*)
module DeprecatedAPIUsage = struct
let checker context an = CTL.False, None
end

@ -0,0 +1,15 @@
(*
* Copyright (c) 2016 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*)
module DeprecatedAPIUsage :
sig
val checker :
CLintersContext.context -> Ctl_parser_types.ast_node ->
CTL.t * CIssue.issue_desc option
end
Loading…
Cancel
Save