diff --git a/infer/src/clang/cFrontend_decl.ml b/infer/src/clang/cFrontend_decl.ml index 989f8483d..67a9df64f 100644 --- a/infer/src/clang/cFrontend_decl.ml +++ b/infer/src/clang/cFrontend_decl.ml @@ -59,7 +59,7 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron incr CFrontend_config.procedures_attempted ; let recover () = Typ.Procname.Hash.remove cfg procname ; - let method_kind = CMethod_signature.ms_get_method_kind ms in + let method_kind = ms.CMethodSignature.method_kind in CMethod_trans.create_external_procdesc cfg procname method_kind None in let pp_context fmt () = @@ -108,8 +108,8 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron match body_opt with | Some body -> (* Only in the case the function declaration has a defined body we create a procdesc *) - let procname = CMethod_signature.ms_get_name ms in - let return_param_typ_opt = CMethod_signature.ms_get_return_param_typ ms in + let procname = ms.CMethodSignature.name in + let return_param_typ_opt = ms.CMethodSignature.return_param_typ in if CMethod_trans.create_local_procdesc trans_unit_ctx cfg tenv ms [body] captured_vars then add_method trans_unit_ctx tenv cfg CContext.ContextNoCls procname body ms @@ -129,8 +129,8 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron in match body_opt with | Some body -> - let procname = CMethod_signature.ms_get_name ms in - let return_param_typ_opt = CMethod_signature.ms_get_return_param_typ ms in + let procname = ms.CMethodSignature.name in + let return_param_typ_opt = ms.CMethodSignature.return_param_typ in let ms', procname' = if is_destructor then ( (* For a destructor we create two procedures: a destructor wrapper and an inner destructor *) @@ -145,10 +145,9 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron Config.clang_inner_destructor_prefix ^ Typ.Procname.get_method procname in let ms' = - CMethod_signature.replace_name_ms ms - (Typ.Procname.objc_cpp_replace_method_name procname new_method_name) + {ms with name= Typ.Procname.objc_cpp_replace_method_name procname new_method_name} in - let procname' = CMethod_signature.ms_get_name ms' in + let procname' = ms'.CMethodSignature.name in (ms', procname') ) else (ms, procname) in @@ -340,7 +339,7 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron Option.value_exn (Pvar.get_initializer_pname global) in let ms = - CMethod_signature.make_ms procname [] Ast_expressions.create_void_type [] + CMethodSignature.mk procname [] Ast_expressions.create_void_type [] decl_info.Clang_ast_t.di_source_range ProcAttributes.C_FUNCTION trans_unit_ctx.CFrontend_config.lang None None None `None in diff --git a/infer/src/clang/cMethodSignature.ml b/infer/src/clang/cMethodSignature.ml new file mode 100644 index 000000000..93c2ba844 --- /dev/null +++ b/infer/src/clang/cMethodSignature.ml @@ -0,0 +1,76 @@ +(* + * Copyright (c) 2013 - 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. + *) + +open! IStd + +(** Define the signature of a method consisting of its name, its arguments, return type, location + and whether its an instance method. *) + +module F = Format + +type t = + { name: Typ.Procname.t + ; access: Clang_ast_t.access_specifier + ; args: (Mangled.t * Clang_ast_t.qual_type) list + ; ret_type: Clang_ast_t.qual_type + ; attributes: Clang_ast_t.attribute list + ; loc: Clang_ast_t.source_range + ; method_kind: ProcAttributes.clang_method_kind + ; is_cpp_virtual: bool + ; is_cpp_nothrow: bool + ; lang: CFrontend_config.clang_lang + ; pointer_to_parent: Clang_ast_t.pointer option + ; pointer_to_property_opt: Clang_ast_t.pointer option + ; (* If set then method is a getter/setter *) + return_param_typ: Typ.t option } + +(* A method is a getter if it has a link to a property and *) +(* it has 1 argument (this includes self) *) +let is_getter {pointer_to_property_opt; args} = + Option.is_some pointer_to_property_opt && Int.equal (List.length args) 1 + + +(* A method is a setter if it has a link to a property and *) +(* it has 2 argument (this includes self) *) +let is_setter {pointer_to_property_opt; args} = + Option.is_some pointer_to_property_opt && Int.equal (List.length args) 2 + + +let mk name args ret_type attributes loc method_kind ?is_cpp_virtual ?is_cpp_nothrow lang + pointer_to_parent pointer_to_property_opt return_param_typ access = + let is_cpp_virtual = Option.value is_cpp_virtual ~default:false in + let is_cpp_nothrow = Option.value is_cpp_nothrow ~default:false in + { name + ; access + ; args + ; ret_type + ; attributes + ; loc + ; method_kind + ; is_cpp_virtual + ; is_cpp_nothrow + ; lang + ; pointer_to_parent + ; pointer_to_property_opt + ; return_param_typ } + + +let pp fmt ms = + let pp_arg fmt (mangled, qual_type) = + F.fprintf fmt "%a, %a" Mangled.pp mangled + (Pp.to_string ~f:CAst_utils.string_of_qual_type) + qual_type + in + Format.fprintf fmt "Method %a [%a]->%a %a" + (Pp.to_string ~f:Typ.Procname.to_string) + ms.name (Pp.comma_seq pp_arg) ms.args + (Pp.to_string ~f:Clang_ast_extend.type_ptr_to_string) + ms.ret_type.Clang_ast_t.qt_type_ptr + (Pp.to_string ~f:Clang_ast_j.string_of_source_range) + ms.loc diff --git a/infer/src/clang/cMethodSignature.mli b/infer/src/clang/cMethodSignature.mli new file mode 100644 index 000000000..c7fb4ad0a --- /dev/null +++ b/infer/src/clang/cMethodSignature.mli @@ -0,0 +1,42 @@ +(* + * Copyright (c) 2013 - 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. + *) + +open! IStd + +(** Define the signature of a method consisting of its name, its arguments, return type, location + and whether its an instance method. *) + +type t = + { name: Typ.Procname.t + ; access: Clang_ast_t.access_specifier + ; args: (Mangled.t * Clang_ast_t.qual_type) list + ; ret_type: Clang_ast_t.qual_type + ; attributes: Clang_ast_t.attribute list + ; loc: Clang_ast_t.source_range + ; method_kind: ProcAttributes.clang_method_kind + ; is_cpp_virtual: bool + ; is_cpp_nothrow: bool + ; lang: CFrontend_config.clang_lang + ; pointer_to_parent: Clang_ast_t.pointer option + ; pointer_to_property_opt: Clang_ast_t.pointer option + ; (* If set then method is a getter/setter *) + return_param_typ: Typ.t option } + +val is_getter : t -> bool + +val is_setter : t -> bool + +val mk : + Typ.Procname.t -> (Mangled.t * Clang_ast_t.qual_type) list -> Clang_ast_t.qual_type + -> Clang_ast_t.attribute list -> Clang_ast_t.source_range -> ProcAttributes.clang_method_kind + -> ?is_cpp_virtual:bool -> ?is_cpp_nothrow:bool -> CFrontend_config.clang_lang + -> Clang_ast_t.pointer option -> Clang_ast_t.pointer option -> Typ.t option + -> Clang_ast_t.access_specifier -> t + +val pp : Format.formatter -> t -> unit diff --git a/infer/src/clang/cMethod_signature.ml b/infer/src/clang/cMethod_signature.ml deleted file mode 100644 index 7f9f69436..000000000 --- a/infer/src/clang/cMethod_signature.ml +++ /dev/null @@ -1,100 +0,0 @@ -(* - * Copyright (c) 2013 - 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. - *) - -open! IStd - -(** Define the signature of a method consisting of its name, its arguments, *) - -(** return type, location and whether its an instance method. *) - -type method_signature = - { mutable name: Typ.Procname.t - ; access: Clang_ast_t.access_specifier - ; args: (Mangled.t * Clang_ast_t.qual_type) list - ; ret_type: Clang_ast_t.qual_type - ; attributes: Clang_ast_t.attribute list - ; loc: Clang_ast_t.source_range - ; method_kind: ProcAttributes.clang_method_kind - ; is_cpp_virtual: bool - ; is_cpp_nothrow: bool - ; language: CFrontend_config.clang_lang - ; pointer_to_parent: Clang_ast_t.pointer option - ; pointer_to_property_opt: Clang_ast_t.pointer option - ; (* If set then method is a getter/setter *) - return_param_typ: Typ.t option } - -let ms_get_name {name} = name - -let ms_set_name ms name = ms.name <- name - -let ms_get_access {access} = access - -let ms_get_args {args} = args - -let ms_get_ret_type {ret_type} = ret_type - -let ms_get_attributes {attributes} = attributes - -let ms_get_loc {loc} = loc - -let ms_get_method_kind {method_kind} = method_kind - -let ms_is_cpp_virtual {is_cpp_virtual} = is_cpp_virtual - -let ms_is_cpp_nothrow {is_cpp_nothrow} = is_cpp_nothrow - -let ms_get_lang {language} = language - -let ms_get_pointer_to_parent {pointer_to_parent} = pointer_to_parent - -let ms_get_pointer_to_property_opt {pointer_to_property_opt} = pointer_to_property_opt - -let ms_get_return_param_typ {return_param_typ} = return_param_typ - -(* A method is a getter if it has a link to a property and *) -(* it has 1 argument (this includes self) *) -let ms_is_getter {pointer_to_property_opt; args} = - Option.is_some pointer_to_property_opt && Int.equal (List.length args) 1 - - -(* A method is a setter if it has a link to a property and *) -(* it has 2 argument (this includes self) *) -let ms_is_setter {pointer_to_property_opt; args} = - Option.is_some pointer_to_property_opt && Int.equal (List.length args) 2 - - -let make_ms name args ret_type attributes loc method_kind ?is_cpp_virtual ?is_cpp_nothrow language - pointer_to_parent pointer_to_property_opt return_param_typ access = - let booloption_to_bool = function Some b -> b | None -> false in - let is_cpp_virtual = booloption_to_bool is_cpp_virtual in - let is_cpp_nothrow = booloption_to_bool is_cpp_nothrow in - { name - ; access - ; args - ; ret_type - ; attributes - ; loc - ; method_kind - ; is_cpp_virtual - ; is_cpp_nothrow - ; language - ; pointer_to_parent - ; pointer_to_property_opt - ; return_param_typ } - - -let replace_name_ms ms name = {ms with name} - -let ms_to_string ms = - "Method " ^ Typ.Procname.to_string ms.name ^ " " - ^ IList.to_string - (fun (s1, s2) -> Mangled.to_string s1 ^ ", " ^ CAst_utils.string_of_qual_type s2) - ms.args - ^ "->" ^ Clang_ast_extend.type_ptr_to_string ms.ret_type.Clang_ast_t.qt_type_ptr ^ " " - ^ Clang_ast_j.string_of_source_range ms.loc diff --git a/infer/src/clang/cMethod_signature.mli b/infer/src/clang/cMethod_signature.mli deleted file mode 100644 index b4d5db767..000000000 --- a/infer/src/clang/cMethod_signature.mli +++ /dev/null @@ -1,59 +0,0 @@ -(* - * Copyright (c) 2013 - 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. - *) - -open! IStd - -(** Define the signature of a method consisting of its name, its arguments, *) - -(** return type, location and whether its an instance method. *) - -type method_signature - -val ms_get_name : method_signature -> Typ.Procname.t - -val ms_set_name : method_signature -> Typ.Procname.t -> unit - -val ms_get_access : method_signature -> Clang_ast_t.access_specifier - -val ms_get_args : method_signature -> (Mangled.t * Clang_ast_t.qual_type) list - -val ms_get_ret_type : method_signature -> Clang_ast_t.qual_type - -val ms_get_attributes : method_signature -> Clang_ast_t.attribute list - -val ms_get_loc : method_signature -> Clang_ast_t.source_range - -val ms_get_method_kind : method_signature -> ProcAttributes.clang_method_kind - -val ms_is_cpp_virtual : method_signature -> bool - -val ms_is_cpp_nothrow : method_signature -> bool - -val ms_get_lang : method_signature -> CFrontend_config.clang_lang - -val ms_get_pointer_to_parent : method_signature -> Clang_ast_t.pointer option - -val ms_get_pointer_to_property_opt : method_signature -> Clang_ast_t.pointer option - -val ms_get_return_param_typ : method_signature -> Typ.t option - -val ms_is_getter : method_signature -> bool - -val ms_is_setter : method_signature -> bool - -val make_ms : - Typ.Procname.t -> (Mangled.t * Clang_ast_t.qual_type) list -> Clang_ast_t.qual_type - -> Clang_ast_t.attribute list -> Clang_ast_t.source_range -> ProcAttributes.clang_method_kind - -> ?is_cpp_virtual:bool -> ?is_cpp_nothrow:bool -> CFrontend_config.clang_lang - -> Clang_ast_t.pointer option -> Clang_ast_t.pointer option -> Typ.t option - -> Clang_ast_t.access_specifier -> method_signature - -val replace_name_ms : method_signature -> Typ.Procname.t -> method_signature - -val ms_to_string : method_signature -> string diff --git a/infer/src/clang/cMethod_trans.ml b/infer/src/clang/cMethod_trans.ml index 674d0813d..d0ad0b092 100644 --- a/infer/src/clang/cMethod_trans.ml +++ b/infer/src/clang/cMethod_trans.ml @@ -175,9 +175,8 @@ let build_method_signature trans_unit_ctx tenv decl_info procname function_metho let is_cpp_virtual = is_cpp_virtual function_method_decl_info in let is_cpp_nothrow = is_cpp_nothrow function_method_decl_info in let access = decl_info.Clang_ast_t.di_access in - CMethod_signature.make_ms procname parameters tp attributes source_range method_kind - ~is_cpp_virtual ~is_cpp_nothrow lang parent_pointer pointer_to_property_opt - return_param_type_opt access + CMethodSignature.mk procname parameters tp attributes source_range method_kind ~is_cpp_virtual + ~is_cpp_nothrow lang parent_pointer pointer_to_property_opt return_param_type_opt access let get_init_list_instrs method_decl_info = @@ -247,20 +246,19 @@ let method_signature_of_pointer trans_unit_ctx tenv pointer = let get_method_name_from_clang tenv ms_opt = match ms_opt with | Some ms -> ( - match CAst_utils.get_decl_opt (CMethod_signature.ms_get_pointer_to_parent ms) with + match CAst_utils.get_decl_opt ms.CMethodSignature.pointer_to_parent with | Some decl -> ( ignore (CType_decl.add_types_from_decl_to_tenv tenv decl) ; match ObjcCategory_decl.get_base_class_name_from_category decl with | Some class_typename -> - let procname = CMethod_signature.ms_get_name ms in + let procname = ms.CMethodSignature.name in let new_procname = Typ.Procname.replace_class procname class_typename in - CMethod_signature.ms_set_name ms new_procname ; - Some ms + Some new_procname | None -> - Some ms ) + Some ms.CMethodSignature.name ) | None -> - Some ms ) + Some ms.CMethodSignature.name ) | None -> None @@ -294,7 +292,7 @@ let get_class_name_method_call_from_clang trans_unit_ctx tenv obj_c_message_expr | Some pointer -> ( match method_signature_of_pointer trans_unit_ctx tenv pointer with | Some ms -> ( - match CMethod_signature.ms_get_name ms with + match ms.CMethodSignature.name with | Typ.Procname.ObjC_Cpp objc_cpp -> Some (Typ.Procname.ObjC_Cpp.get_class_type_name objc_cpp) | _ -> @@ -344,19 +342,14 @@ let get_formal_parameters tenv ms = let should_add_pointer name ms = let is_objc_self = String.equal name CFrontend_config.self - && CFrontend_config.equal_clang_lang - (CMethod_signature.ms_get_lang ms) - CFrontend_config.ObjC + && CFrontend_config.equal_clang_lang ms.CMethodSignature.lang CFrontend_config.ObjC in let is_cxx_this = String.equal name CFrontend_config.this - && CFrontend_config.equal_clang_lang - (CMethod_signature.ms_get_lang ms) - CFrontend_config.CPP + && CFrontend_config.equal_clang_lang ms.CMethodSignature.lang CFrontend_config.CPP in is_objc_self - && ProcAttributes.clang_method_kind_equal - (CMethod_signature.ms_get_method_kind ms) + && ProcAttributes.clang_method_kind_equal ms.CMethodSignature.method_kind ProcAttributes.OBJC_INSTANCE || is_cxx_this in @@ -368,11 +361,11 @@ let get_formal_parameters tenv ms = let typ = CType_decl.qual_type_to_sil_type tenv qt in (mangled, typ) :: defined_parameters pl' in - defined_parameters (CMethod_signature.ms_get_args ms) + defined_parameters ms.CMethodSignature.args let get_return_type tenv ms = - let return_type = CMethod_signature.ms_get_ret_type ms in + let return_type = ms.CMethodSignature.ret_type in CType_decl.qual_type_to_sil_type tenv return_type @@ -520,7 +513,7 @@ let get_byval_args_indices ~shift args = let get_objc_property_accessor tenv ms = let open Clang_ast_t in - match CAst_utils.get_decl_opt (CMethod_signature.ms_get_pointer_to_property_opt ms) with + match CAst_utils.get_decl_opt ms.CMethodSignature.pointer_to_property_opt with | Some ObjCPropertyDecl (_, _, obj_c_property_decl_info) -> ( let ivar_decl_ref = obj_c_property_decl_info.Clang_ast_t.opdi_ivar_decl in @@ -528,7 +521,7 @@ let get_objc_property_accessor tenv ms = | Some ObjCIvarDecl (_, {ni_name}, _, _, _) -> ( let class_tname = - match CMethod_signature.ms_get_name ms with + match ms.CMethodSignature.name with | Typ.Procname.ObjC_Cpp objc_cpp -> Typ.Procname.ObjC_Cpp.get_class_type_name objc_cpp | _ -> @@ -542,9 +535,9 @@ let get_objc_property_accessor tenv ms = List.find ~f:(fun (name, _, _) -> Typ.Fieldname.equal name field_name) fields in match field_opt with - | Some field when CMethod_signature.ms_is_getter ms -> + | Some field when CMethodSignature.is_getter ms -> Some (ProcAttributes.Objc_getter field) - | Some field when CMethod_signature.ms_is_setter ms -> + | Some field when CMethodSignature.is_setter ms -> Some (ProcAttributes.Objc_setter field) | _ -> None ) @@ -560,17 +553,15 @@ let get_objc_property_accessor tenv ms = let create_local_procdesc ?(set_objc_accessor_attr= false) trans_unit_ctx cfg tenv ms fbody captured = let defined = not (Int.equal (List.length fbody) 0) in - let proc_name = CMethod_signature.ms_get_name ms in + let proc_name = ms.CMethodSignature.name in let pname = Typ.Procname.to_string proc_name in - let attributes = sil_func_attributes_of_attributes (CMethod_signature.ms_get_attributes ms) in - let method_ret_type = CMethod_signature.ms_get_ret_type ms in - let method_annotation = - sil_method_annotation_of_args (CMethod_signature.ms_get_args ms) method_ret_type - in - let clang_method_kind = CMethod_signature.ms_get_method_kind ms in - let is_cpp_nothrow = CMethod_signature.ms_is_cpp_nothrow ms in + let attributes = sil_func_attributes_of_attributes ms.CMethodSignature.attributes in + let method_ret_type = ms.CMethodSignature.ret_type in + let method_annotation = sil_method_annotation_of_args ms.CMethodSignature.args method_ret_type in + let clang_method_kind = ms.CMethodSignature.method_kind in + let is_cpp_nothrow = ms.CMethodSignature.is_cpp_nothrow in let access = - match CMethod_signature.ms_get_access ms with + match ms.CMethodSignature.access with | `None -> PredSymb.Default | `Private -> @@ -586,16 +577,14 @@ let create_local_procdesc ?(set_objc_accessor_attr= false) trans_unit_ctx cfg te (* Captured variables for blocks are treated as parameters *) let formals = captured_mangled @ formals in let const_formals = - get_const_args_indices ~shift:(List.length captured_mangled) - (CMethod_signature.ms_get_args ms) + get_const_args_indices ~shift:(List.length captured_mangled) ms.CMethodSignature.args in let by_vals = - get_byval_args_indices ~shift:(List.length captured_mangled) - (CMethod_signature.ms_get_args ms) + get_byval_args_indices ~shift:(List.length captured_mangled) ms.CMethodSignature.args in - let source_range = CMethod_signature.ms_get_loc ms in + let source_range = ms.CMethodSignature.loc in L.(debug Capture Verbose) "@\nCreating a new procdesc for function: '%s'@\n@." pname ; - L.(debug Capture Verbose) "@\nms = %s@\n@." (CMethod_signature.ms_to_string ms) ; + L.(debug Capture Verbose) "@\nms = %a@\n@." CMethodSignature.pp ms ; L.(debug Capture Verbose) "@\nbyvals = [ %s ]@\n@." (String.concat ~sep:", " (List.map by_vals ~f:string_of_int)) ; @@ -662,7 +651,7 @@ let create_procdesc_with_pointer context pointer class_name_opt name = ignore (create_local_procdesc context.translation_unit_context context.cfg context.tenv callee_ms [] []) ; - CMethod_signature.ms_get_name callee_ms + callee_ms.CMethodSignature.name | None -> let callee_name, method_kind = match class_name_opt with diff --git a/infer/src/clang/cMethod_trans.mli b/infer/src/clang/cMethod_trans.mli index a6bffcb80..22c934672 100644 --- a/infer/src/clang/cMethod_trans.mli +++ b/infer/src/clang/cMethod_trans.mli @@ -24,7 +24,7 @@ val should_add_return_param : Typ.t -> is_objc_method:bool -> bool val create_local_procdesc : ?set_objc_accessor_attr:bool -> CFrontend_config.translation_unit_context -> Cfg.t -> Tenv.t - -> CMethod_signature.method_signature -> Clang_ast_t.stmt list -> (Pvar.t * Typ.t) list -> bool + -> CMethodSignature.t -> Clang_ast_t.stmt list -> (Pvar.t * Typ.t) list -> bool val create_external_procdesc : Cfg.t -> Typ.Procname.t -> ProcAttributes.clang_method_kind -> (Typ.t * Typ.t list) option @@ -43,14 +43,13 @@ val get_class_name_method_call_from_clang : val method_signature_of_decl : CFrontend_config.translation_unit_context -> Tenv.t -> Clang_ast_t.decl -> CModule_type.block_data option - -> CMethod_signature.method_signature * Clang_ast_t.stmt option * CModule_type.instr_type list + -> CMethodSignature.t * Clang_ast_t.stmt option * CModule_type.instr_type list val method_signature_of_pointer : CFrontend_config.translation_unit_context -> Tenv.t -> Clang_ast_t.pointer - -> CMethod_signature.method_signature option + -> CMethodSignature.t option -val get_method_name_from_clang : - Tenv.t -> CMethod_signature.method_signature option -> CMethod_signature.method_signature option +val get_method_name_from_clang : Tenv.t -> CMethodSignature.t option -> Typ.Procname.t option val create_procdesc_with_pointer : CContext.t -> Clang_ast_t.pointer -> Typ.Name.t option -> string -> Typ.Procname.t diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index 647ac5c66..c9fe6c786 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -42,8 +42,8 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s in let proc_name = match CMethod_trans.get_method_name_from_clang context.tenv ms_opt with - | Some ms -> - CMethod_signature.ms_get_name ms + | Some name -> + name | None -> (* fall back to our method resolution if clang's fails *) let class_name = @@ -66,12 +66,12 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s ignore (CMethod_trans.create_local_procdesc context.translation_unit_context context.cfg context.tenv ms [] []) ; - (CMethod_signature.ms_get_name ms, CMethod_trans.MCNoVirtual) + (ms.CMethodSignature.name, CMethod_trans.MCNoVirtual) | None, Some ms -> ignore (CMethod_trans.create_local_procdesc context.translation_unit_context context.cfg context.tenv ms [] []) ; - if CMethod_signature.ms_is_getter ms || CMethod_signature.ms_is_setter ms then + if CMethodSignature.is_getter ms || CMethodSignature.is_setter ms then (proc_name, CMethod_trans.MCNoVirtual) else (proc_name, mc_type) | _ -> @@ -589,7 +589,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s let is_instance_method = match ms_opt with | Some ms -> ( - match CMethod_signature.ms_get_method_kind ms with + match ms.CMethodSignature.method_kind with | ProcAttributes.CPP_INSTANCE | ProcAttributes.OBJC_INSTANCE -> true | _ -> @@ -599,7 +599,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s (* might happen for methods that are not exported yet (some templates). *) in let is_cpp_virtual = - match ms_opt with Some ms -> CMethod_signature.ms_is_cpp_virtual ms | _ -> false + match ms_opt with Some ms -> ms.CMethodSignature.is_cpp_virtual | _ -> false in let extra_exps, extra_instrs = if is_instance_method then @@ -644,18 +644,17 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s if is_inner_destructor then match ms_opt with | Some ms -> - let procname = CMethod_signature.ms_get_name ms in + let procname = ms.CMethodSignature.name in let new_method_name = Config.clang_inner_destructor_prefix ^ Typ.Procname.get_method procname in let ms' = - CMethod_signature.replace_name_ms ms - (Typ.Procname.objc_cpp_replace_method_name procname new_method_name) + {ms with name= Typ.Procname.objc_cpp_replace_method_name procname new_method_name} in ignore (CMethod_trans.create_local_procdesc context.translation_unit_context context.cfg context.tenv ms' [] []) ; - CMethod_signature.ms_get_name ms' + ms'.CMethodSignature.name | None -> CMethod_trans.create_procdesc_with_pointer context decl_ptr (Some class_typename) method_name diff --git a/infer/src/clang/cTrans_models.ml b/infer/src/clang/cTrans_models.ml index 3dab4d496..32f48a1b4 100644 --- a/infer/src/clang/cTrans_models.ml +++ b/infer/src/clang/cTrans_models.ml @@ -75,7 +75,7 @@ let get_predefined_ms_method condition class_name method_name method_kind mk_pro mk_procname class_name method_name method_kind in let ms = - CMethod_signature.make_ms procname arguments return_type attributes + CMethodSignature.mk procname arguments return_type attributes (CAst_utils.dummy_source_range ()) ProcAttributes.C_FUNCTION lang None None None `None in diff --git a/infer/src/clang/cTrans_models.mli b/infer/src/clang/cTrans_models.mli index e87e72d89..a58ccdd45 100644 --- a/infer/src/clang/cTrans_models.mli +++ b/infer/src/clang/cTrans_models.mli @@ -29,4 +29,4 @@ val is_modeled_attribute : string -> bool val get_predefined_model_method_signature : Typ.Name.t -> string -> (Typ.Name.t -> string -> Typ.Procname.ObjC_Cpp.kind -> Typ.Procname.t) - -> CFrontend_config.clang_lang -> CMethod_signature.method_signature option + -> CFrontend_config.clang_lang -> CMethodSignature.t option diff --git a/infer/src/istd/IList.ml b/infer/src/istd/IList.ml index 3aa4d1c0c..f81e6932d 100644 --- a/infer/src/istd/IList.ml +++ b/infer/src/istd/IList.ml @@ -93,11 +93,6 @@ let rec fold_last l ~init ~f ~f_last = fold_last tl ~init:(f init hd) ~f ~f_last -let to_string f l = - let rec aux l = match l with [] -> "" | [s] -> f s | s :: rest -> f s ^ ", " ^ aux rest in - "[" ^ aux l ^ "]" - - let uncons_exn = function [] -> failwith "uncons_exn" | hd :: tl -> (hd, tl) let append_no_duplicates eq list1 list2 = diff --git a/infer/src/istd/IList.mli b/infer/src/istd/IList.mli index 3871292a9..8a52bbea0 100644 --- a/infer/src/istd/IList.mli +++ b/infer/src/istd/IList.mli @@ -25,8 +25,6 @@ val inter : ('a -> 'a -> int) -> 'a list -> 'a list -> 'a list val fold_last : 'a list -> init:'b -> f:('b -> 'a -> 'b) -> f_last:('b -> 'a -> 'b) -> 'b (** like fold, but apply f_last to the last element *) -val to_string : ('a -> string) -> 'a list -> string - val uncons_exn : 'a list -> 'a * 'a list (** deconstruct a list, like hd_exn and tl_exn *)