diff --git a/infer/src/clang/cAst_utils.ml b/infer/src/clang/cAst_utils.ml index f29395cf8..cbdc589d6 100644 --- a/infer/src/clang/cAst_utils.ml +++ b/infer/src/clang/cAst_utils.ml @@ -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 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 | Some ObjCInterfaceType (_, decl_ptr) -> get_decl decl_ptr | 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 | _ -> 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 = match if_decl with diff --git a/infer/src/clang/cAst_utils.mli b/infer/src/clang/cAst_utils.mli index ac7c1f734..c64e0d435 100644 --- a/infer/src/clang/cAst_utils.mli +++ b/infer/src/clang/cAst_utils.mli @@ -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_is_typedef_named : Clang_ast_types.t_ptr -> string -> bool + (** 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 diff --git a/infer/src/clang/cFrontend_errors.ml b/infer/src/clang/cFrontend_errors.ml index 456556320..7df490de8 100644 --- a/infer/src/clang/cFrontend_errors.ml +++ b/infer/src/clang/cFrontend_errors.ml @@ -30,7 +30,8 @@ let decl_checkers_list = (* List of checkers on stmts *that return 0 or 1 issue* *) let stmt_single_checkers_list = [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 diff --git a/infer/src/opensource/GraphQL.ml b/infer/src/opensource/GraphQL.ml new file mode 100644 index 000000000..b594f6f33 --- /dev/null +++ b/infer/src/opensource/GraphQL.ml @@ -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 diff --git a/infer/src/opensource/GraphQL.mli b/infer/src/opensource/GraphQL.mli new file mode 100644 index 000000000..5af1dc03f --- /dev/null +++ b/infer/src/opensource/GraphQL.mli @@ -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