diff --git a/infer/src/IR/Pvar.ml b/infer/src/IR/Pvar.ml index 059601856..36866a901 100644 --- a/infer/src/IR/Pvar.ml +++ b/infer/src/IR/Pvar.ml @@ -261,7 +261,7 @@ let get_initializer_pname {pv_name; pv_kind} = | Some file -> let mangled = SourceFile.to_string file |> Utils.string_crc_hex32 in Typ.Procname.C - (Typ.Procname.c (QualifiedCppName.of_qual_string name) mangled Typ.NoTemplate) + (Typ.Procname.c (QualifiedCppName.of_qual_string name) mangled [] Typ.NoTemplate) |> Option.return | None -> None diff --git a/infer/src/IR/Typ.ml b/infer/src/IR/Typ.ml index 3d51d4045..27de5fdb2 100644 --- a/infer/src/IR/Typ.ml +++ b/infer/src/IR/Typ.ml @@ -837,7 +837,11 @@ being the name of the struct, [None] means the parameter is of some other type. end (** Type of c procedure names. *) - type c = {name: QualifiedCppName.t; mangled: string option; template_args: template_spec_info} + type c = + { name: QualifiedCppName.t + ; mangled: string option + ; parameters: Parameter.t list + ; template_args: template_spec_info } [@@deriving compare] (** Type of Objective C block names. *) @@ -867,10 +871,16 @@ being the name of the struct, [None] means the parameter is of some other type. let empty_block = Block "" - let c name mangled template_args = {name; mangled= Some mangled; template_args} + let c name mangled parameters template_args = + {name; mangled= Some mangled; parameters; template_args} + let from_string_c_fun (name: string) = - C {name= QualifiedCppName.of_qual_string name; mangled= None; template_args= NoTemplate} + C + { name= QualifiedCppName.of_qual_string name + ; mangled= None + ; parameters= [] + ; template_args= NoTemplate } let with_block_parameters base blocks = WithBlockParameters (base, blocks) @@ -990,9 +1000,19 @@ being the name of the struct, [None] means the parameter is of some other type. (** to_string for C_function type *) - let to_readable_string (c1, c2) verbose = - let plain = QualifiedCppName.to_qual_string c1 in - if verbose then match c2 with None -> plain | Some s -> plain ^ "{" ^ s ^ "}" else plain + let c_function_to_string {name; mangled; parameters} verbose = + let plain = QualifiedCppName.to_qual_string name in + match verbose with + | Simple -> + plain ^ "()" + | Non_verbose -> + plain + | Verbose -> + match mangled with + | None -> + plain ^ Parameter.parameters_to_string parameters + | Some s -> + plain ^ Parameter.parameters_to_string parameters ^ "{" ^ s ^ "}" let with_blocks_parameters_to_string base blocks to_string_f = @@ -1005,8 +1025,8 @@ being the name of the struct, [None] means the parameter is of some other type. match pn with | Java j -> Java.to_string j Verbose - | C {name; mangled} -> - to_readable_string (name, mangled) true + | C osig -> + c_function_to_string osig Verbose | ObjC_Cpp osig -> ObjC_Cpp.to_string osig Verbose | Block name -> @@ -1022,8 +1042,8 @@ being the name of the struct, [None] means the parameter is of some other type. match p with | Java j -> Java.to_string j Non_verbose - | C {name; mangled} -> - to_readable_string (name, mangled) false + | C osig -> + c_function_to_string osig Non_verbose | ObjC_Cpp osig -> ObjC_Cpp.to_string osig Non_verbose | Block name -> @@ -1039,8 +1059,8 @@ being the name of the struct, [None] means the parameter is of some other type. match p with | Java j -> Java.to_string ~withclass j Simple - | C {name; mangled} -> - to_readable_string (name, mangled) false ^ "()" + | C osig -> + c_function_to_string osig Simple | ObjC_Cpp osig -> ObjC_Cpp.to_string osig Simple | Block _ -> diff --git a/infer/src/IR/Typ.mli b/infer/src/IR/Typ.mli index 6a12e2c31..edb8dfcea 100644 --- a/infer/src/IR/Typ.mli +++ b/infer/src/IR/Typ.mli @@ -423,7 +423,10 @@ module Procname : sig (** Type of c procedure names. *) type c = private - {name: QualifiedCppName.t; mangled: string option; template_args: template_spec_info} + { name: QualifiedCppName.t + ; mangled: string option + ; parameters: Parameter.t list + ; template_args: template_spec_info } (** Type of Objective C block names. *) type block_name @@ -466,7 +469,7 @@ module Procname : sig module SQLiteList : SqliteUtils.Data with type t = t list - val c : QualifiedCppName.t -> string -> template_spec_info -> c + val c : QualifiedCppName.t -> string -> Parameter.t list -> template_spec_info -> c (** Create a C procedure name from plain and mangled name. *) val empty_block : t diff --git a/infer/src/clang/CType_decl.ml b/infer/src/clang/CType_decl.ml index cf71e2c1d..1b9494fc4 100644 --- a/infer/src/clang/CType_decl.ml +++ b/infer/src/clang/CType_decl.ml @@ -508,7 +508,7 @@ and get_template_info tenv (fdi: Clang_ast_t.function_decl_info) = Typ.NoTemplate -and mk_c_function ?tenv name function_decl_info_opt = +and mk_c_function ?tenv name function_decl_info_opt parameters = let file = match function_decl_info_opt with | Some (decl_info, function_decl_info) -> ( @@ -547,7 +547,7 @@ and mk_c_function ?tenv name function_decl_info_opt = let mangled = file ^ mangled_name in if String.is_empty mangled then Typ.Procname.from_string_c_fun (QualifiedCppName.to_qual_string name) - else Typ.Procname.C (Typ.Procname.c name mangled template_info) + else Typ.Procname.C (Typ.Procname.c name mangled parameters template_info) and mk_cpp_method ?tenv class_name method_name ?meth_decl mangled = @@ -605,7 +605,7 @@ and objc_block_procname outer_proc_opt = and procname_from_decl ?tenv ?block_return_type ?outer_proc meth_decl = let open Clang_ast_t in - let _ = + let parameters = match tenv with | Some tenv -> let parameters = @@ -621,7 +621,7 @@ and procname_from_decl ?tenv ?block_return_type ?outer_proc meth_decl = match meth_decl with | FunctionDecl (decl_info, name_info, _, fdi) -> let name = CAst_utils.get_qualified_name name_info in - mk_c_function ?tenv name (Some (decl_info, fdi)) + mk_c_function ?tenv name (Some (decl_info, fdi)) parameters | CXXMethodDecl (decl_info, name_info, _, fdi, mdi) | CXXConstructorDecl (decl_info, name_info, _, fdi, mdi) | CXXConversionDecl (decl_info, name_info, _, fdi, mdi) @@ -711,7 +711,7 @@ module CProcname = struct module NoAstDecl = struct let c_function_of_string tenv name = let qual_name = QualifiedCppName.of_qual_string name in - mk_c_function ~tenv qual_name None + mk_c_function ~tenv qual_name None [] let cpp_method_of_string tenv class_name method_name =