Rename Procname.from_string

master
Andrzej Kotulski 9 years ago
parent f1daf147b3
commit 35400dd4f6

@ -222,7 +222,7 @@ let rec _find_normal_variable_letderef (seen : Sil.ExpSet.t) node id : Sil.dexp
if !verbose then (L.d_str "find_normal_variable_letderef defining "; Sil.d_exp e; L.d_ln ()); if !verbose then (L.d_str "find_normal_variable_letderef defining "; Sil.d_exp e; L.d_ln ());
res := _exp_lv_dexp seen node e; res := _exp_lv_dexp seen node e;
true true
| Sil.Call ([id0], Sil.Const (Sil.Cfun pn), (e, _):: _, _, _) when Ident.equal id id0 && Procname.equal pn (Procname.from_string "__cast") -> | Sil.Call ([id0], Sil.Const (Sil.Cfun pn), (e, _):: _, _, _) when Ident.equal id id0 && Procname.equal pn (Procname.from_string_c_fun "__cast") ->
if !verbose then (L.d_str "find_normal_variable_letderef cast on "; Sil.d_exp e; L.d_ln ()); if !verbose then (L.d_str "find_normal_variable_letderef cast on "; Sil.d_exp e; L.d_ln ());
res := _exp_rv_dexp seen node e; res := _exp_rv_dexp seen node e;
true true

@ -347,7 +347,7 @@ let source_file_from_pname pname =
DB.source_file_from_string (Procname.to_string pname) DB.source_file_from_string (Procname.to_string pname)
let source_file_to_pname fname = let source_file_to_pname fname =
Procname.from_string (DB.source_file_to_string fname) Procname.from_string_c_fun (DB.source_file_to_string fname)
(** create clusters of minimal size in the dependence order, with recursive parts grouped together *) (** create clusters of minimal size in the dependence order, with recursive parts grouped together *)
let create_minimal_clusters file_cg exe_env (only_analyze : Procname.Set.t option) : cluster list = let create_minimal_clusters file_cg exe_env (only_analyze : Procname.Set.t option) : cluster list =

@ -1124,9 +1124,9 @@ let filter_out (call_graph: Cg.t) (proc_name: Procname.t) : bool =
if !Config.trace_anal then L.err "===filter_out@."; if !Config.trace_anal then L.err "===filter_out@.";
let slice_out = (* filter out if slicing is active and [proc_name] not in slice *) let slice_out = (* filter out if slicing is active and [proc_name] not in slice *)
(!Config.slice_fun <> "") && (!Config.slice_fun <> "") &&
(Procname.compare (Procname.from_string !Config.slice_fun) proc_name != 0) && (Procname.compare (Procname.from_string_c_fun !Config.slice_fun) proc_name != 0) &&
(Cg.node_defined call_graph proc_name) && (Cg.node_defined call_graph proc_name) &&
not (Cg.calls_recursively call_graph (Procname.from_string !Config.slice_fun) proc_name) in not (Cg.calls_recursively call_graph (Procname.from_string_c_fun !Config.slice_fun) proc_name) in
slice_out slice_out
let check_skipped_procs procs_and_defined_children = let check_skipped_procs procs_and_defined_children =

@ -57,7 +57,7 @@ let aliased_var = ref Vset.empty
let captured_var = ref Vset.empty let captured_var = ref Vset.empty
let is_not_function cfg x = let is_not_function cfg x =
let pname = Procname.from_string (Mangled.to_string (Sil.pvar_get_name x)) in let pname = Procname.from_string_c_fun (Mangled.to_string (Sil.pvar_get_name x)) in
Cfg.Procdesc.find_from_name cfg pname = None Cfg.Procdesc.find_from_name cfg pname = None
let is_captured_pvar pdesc x = let is_captured_pvar pdesc x =

@ -126,7 +126,7 @@ let c_meth_sig_compare osig1 osig2 =
let split_classname package_classname = let split_classname package_classname =
string_split_character package_classname '.' string_split_character package_classname '.'
let from_string (s: string) = C_FUNCTION (s, None) let from_string_c_fun (s: string) = C_FUNCTION (s, None)
let mangled_c_fun (plain: string) (mangled: string) = C_FUNCTION (plain, Some mangled) let mangled_c_fun (plain: string) (mangled: string) = C_FUNCTION (plain, Some mangled)

@ -28,7 +28,7 @@ val compare : t -> t -> int
val equal : t -> t -> bool val equal : t -> t -> bool
(** Convert a string to a proc name *) (** Convert a string to a proc name *)
val from_string : string -> t val from_string_c_fun : string -> t
(** Create a C++ procedure name from plain and mangled name *) (** Create a C++ procedure name from plain and mangled name *)
val mangled_c_fun : string -> string -> t val mangled_c_fun : string -> string -> t

@ -416,7 +416,7 @@ let mk_ptsto_exp_footprint
| Sil.Java -> Sil.Subtype.subtypes in | Sil.Java -> Sil.Subtype.subtypes in
let create_ptsto footprint_part off0 = match root, off0, typ with let create_ptsto footprint_part off0 = match root, off0, typ with
| Sil.Lvar pvar, [], Sil.Tfun _ -> | Sil.Lvar pvar, [], Sil.Tfun _ ->
let fun_name = Procname.from_string (Mangled.to_string (Sil.pvar_get_name pvar)) in let fun_name = Procname.from_string_c_fun (Mangled.to_string (Sil.pvar_get_name pvar)) in
let fun_exp = Sil.Const (Sil.Cfun fun_name) in let fun_exp = Sil.Const (Sil.Cfun fun_name) in
([], Prop.mk_ptsto root (Sil.Eexp (fun_exp, inst)) (Sil.Sizeof (typ, st))) ([], Prop.mk_ptsto root (Sil.Eexp (fun_exp, inst)) (Sil.Sizeof (typ, st)))
| _, [], Sil.Tfun _ -> | _, [], Sil.Tfun _ ->

@ -1130,17 +1130,17 @@ let mem_kind_to_num = function
(** name of the allocation function for the given memory kind *) (** name of the allocation function for the given memory kind *)
let mem_alloc_pname = function let mem_alloc_pname = function
| Mmalloc -> Procname.from_string "malloc" | Mmalloc -> Procname.from_string_c_fun "malloc"
| Mnew -> Procname.from_string "new" | Mnew -> Procname.from_string_c_fun "new"
| Mnew_array -> Procname.from_string "new[]" | Mnew_array -> Procname.from_string_c_fun "new[]"
| Mobjc -> Procname.from_string "alloc" | Mobjc -> Procname.from_string_c_fun "alloc"
(** name of the deallocation function for the given memory kind *) (** name of the deallocation function for the given memory kind *)
let mem_dealloc_pname = function let mem_dealloc_pname = function
| Mmalloc -> Procname.from_string "free" | Mmalloc -> Procname.from_string_c_fun "free"
| Mnew -> Procname.from_string "delete" | Mnew -> Procname.from_string_c_fun "delete"
| Mnew_array -> Procname.from_string "delete[]" | Mnew_array -> Procname.from_string_c_fun "delete[]"
| Mobjc -> Procname.from_string "dealloc" | Mobjc -> Procname.from_string_c_fun "dealloc"
let mem_kind_compare mk1 mk2 = let mem_kind_compare mk1 mk2 =
int_compare (mem_kind_to_num mk1) (mem_kind_to_num mk2) int_compare (mem_kind_to_num mk1) (mem_kind_to_num mk2)
@ -3888,4 +3888,4 @@ let global_error =
(* A block pvar used to explain retain cycles *) (* A block pvar used to explain retain cycles *)
let block_pvar = let block_pvar =
mk_pvar (Mangled.from_string "block") (Procname.from_string "") mk_pvar (Mangled.from_string "block") (Procname.from_string_c_fun "")

@ -251,7 +251,7 @@ let get_session () =
let get_path_pos () = let get_path_pos () =
let pname = match get_prop_tenv_pdesc () with let pname = match get_prop_tenv_pdesc () with
| Some (_, _, pdesc) -> Cfg.Procdesc.get_proc_name pdesc | Some (_, _, pdesc) -> Cfg.Procdesc.get_proc_name pdesc
| None -> Procname.from_string "unknown_procedure" in | None -> Procname.from_string_c_fun "unknown_procedure" in
let nid = get_node_id () in let nid = get_node_id () in
(pname, nid) (pname, nid)

@ -348,13 +348,13 @@ module Builtin = struct
(* register a builtin function name and symbolic execution handler *) (* register a builtin function name and symbolic execution handler *)
let register proc_name_str (sym_exe_fun: sym_exe_builtin) = let register proc_name_str (sym_exe_fun: sym_exe_builtin) =
let proc_name = Procname.from_string proc_name_str in let proc_name = Procname.from_string_c_fun proc_name_str in
Procname.Hash.replace builtin_functions proc_name sym_exe_fun; Procname.Hash.replace builtin_functions proc_name sym_exe_fun;
proc_name proc_name
(* register a builtin plain function name and symbolic execution handler *) (* register a builtin plain function name and symbolic execution handler *)
let register_plain proc_name_str (sym_exe_fun: sym_exe_builtin) = let register_plain proc_name_str (sym_exe_fun: sym_exe_builtin) =
let proc_name = Procname.from_string proc_name_str in let proc_name = Procname.from_string_c_fun proc_name_str in
Hashtbl.replace builtin_plain_functions proc_name_str sym_exe_fun; Hashtbl.replace builtin_plain_functions proc_name_str sym_exe_fun;
proc_name proc_name
@ -503,7 +503,7 @@ let prune_prop tenv condition prop =
let dangerous_functions = let dangerous_functions =
let dangerous_list = ["gets"] in let dangerous_list = ["gets"] in
ref ((list_map Procname.from_string) dangerous_list) ref ((list_map Procname.from_string_c_fun) dangerous_list)
let check_inherently_dangerous_function caller_pname callee_pname = let check_inherently_dangerous_function caller_pname callee_pname =
if list_exists (Procname.equal callee_pname) !dangerous_functions then if list_exists (Procname.equal callee_pname) !dangerous_functions then
@ -748,17 +748,17 @@ let redirect_shared_ptr tenv cfg pname actual_params =
let ptr_to_something typ = ptr_to (fun _ -> true) typ in let ptr_to_something typ = ptr_to (fun _ -> true) typ in
let pname' = match Procname.to_string pname, actual_params with let pname' = match Procname.to_string pname, actual_params with
| "shared_ptr", [(_, this_t); (_, t1)] when ptr_to_shared_ptr this_t && ptr_to_something t1 -> | "shared_ptr", [(_, this_t); (_, t1)] when ptr_to_shared_ptr this_t && ptr_to_something t1 ->
Procname.from_string "__infer_shared_ptr" Procname.from_string_c_fun "__infer_shared_ptr"
| "shared_ptr", [(_, this_t); (_, t1)] when ptr_to_shared_ptr this_t && ref_to_shared_ptr t1 -> | "shared_ptr", [(_, this_t); (_, t1)] when ptr_to_shared_ptr this_t && ref_to_shared_ptr t1 ->
Procname.from_string "__infer_shared_ptr_ref" Procname.from_string_c_fun "__infer_shared_ptr_ref"
| "operator=", [(_, this_t); (_, t1)] when ptr_to_shared_ptr this_t && ref_to_shared_ptr t1 -> | "operator=", [(_, this_t); (_, t1)] when ptr_to_shared_ptr this_t && ref_to_shared_ptr t1 ->
Procname.from_string "__infer_shared_ptr_eq" Procname.from_string_c_fun "__infer_shared_ptr_eq"
| "operator==", [(_, t1); (_, t2)] when ref_to_shared_ptr t1 && ref_to_shared_ptr t2 -> | "operator==", [(_, t1); (_, t2)] when ref_to_shared_ptr t1 && ref_to_shared_ptr t2 ->
Procname.from_string "__infer_shared_ptr_eqeq" Procname.from_string_c_fun "__infer_shared_ptr_eqeq"
| ("operator->" | "operator*"),[(_, t1)] when ptr_to_shared_ptr t1 -> | ("operator->" | "operator*"),[(_, t1)] when ptr_to_shared_ptr t1 ->
Procname.from_string "__infer_shared_ptr_arrow" Procname.from_string_c_fun "__infer_shared_ptr_arrow"
| "~shared_ptr",[(_, t1)] -> | "~shared_ptr",[(_, t1)] ->
Procname.from_string "__infer_shared_ptr_destructor" Procname.from_string_c_fun "__infer_shared_ptr_destructor"
| _ -> pname in | _ -> pname in
if Procname.equal pname pname' then pname if Procname.equal pname pname' then pname
else else
@ -992,7 +992,7 @@ let rec sym_exec cfg tenv pdesc _instr (_prop: Prop.normal Prop.t) path
execute_diverge prop_r path execute_diverge prop_r path
end else begin end else begin
L.d_str "Unknown function pointer "; Sil.d_exp fun_exp; L.d_strln ", returning undefined value."; L.d_str "Unknown function pointer "; Sil.d_exp fun_exp; L.d_strln ", returning undefined value.";
let callee_pname = Procname.from_string "__function_pointer__" in let callee_pname = Procname.from_string_c_fun "__function_pointer__" in
call_unknown_or_scan call_unknown_or_scan
false cfg pdesc tenv prop_r path ret_ids None n_actual_params callee_pname loc false cfg pdesc tenv prop_r path ret_ids None n_actual_params callee_pname loc
end end
@ -2105,7 +2105,7 @@ module ModelBuiltins = struct
let fun_string = Mangled.to_string fun_name in let fun_string = Mangled.to_string fun_name in
L.d_strln ("pthread_create: calling function " ^ fun_string); L.d_strln ("pthread_create: calling function " ^ fun_string);
begin begin
match Specs.get_summary (Procname.from_string fun_string) with match Specs.get_summary (Procname.from_string_c_fun fun_string) with
| None -> assert false | None -> assert false
| Some callee_summary -> | Some callee_summary ->
sym_exec_call sym_exec_call

@ -160,7 +160,7 @@ let get_vararg_type_names
| Sil.Call ([t1], Sil.Const (Sil.Cfun pn), _, _, _):: | Sil.Call ([t1], Sil.Const (Sil.Cfun pn), _, _, _)::
Sil.Set (Sil.Lvar iv, _, Sil.Var t2, _):: is -> Sil.Set (Sil.Lvar iv, _, Sil.Var t2, _):: is ->
(Sil.pvar_equal ivar iv && Ident.equal t1 t2 && (Sil.pvar_equal ivar iv && Ident.equal t1 t2 &&
Procname.equal pn (Procname.from_string "__new_array")) Procname.equal pn (Procname.from_string_c_fun "__new_array"))
|| initializes_array is || initializes_array is
| i:: is -> initializes_array is | i:: is -> initializes_array is
| _ -> false in | _ -> false in

@ -14,7 +14,7 @@ open CFrontend_utils
open Clang_ast_t open Clang_ast_t
let create_empty_procdesc () = let create_empty_procdesc () =
let procname = Procname.from_string "__INFER_$GLOBAL_VAR_env" in let procname = Procname.from_string_c_fun "__INFER_$GLOBAL_VAR_env" in
let open Cfg.Procdesc in let open Cfg.Procdesc in
let proc_attributes = let proc_attributes =
{ {

@ -305,7 +305,7 @@ struct
match qt with match qt with
| Some v -> | Some v ->
CMethod_trans.mk_procname_from_function name v, CTypes_decl.parse_func_type name v CMethod_trans.mk_procname_from_function name v, CTypes_decl.parse_func_type name v
| None -> Procname.from_string name, None in | None -> Procname.from_string_c_fun name, None in
let address_of_function = not context.CContext.is_callee_expression in let address_of_function = not context.CContext.is_callee_expression in
(* If we are not translating a callee expression, then the address of the function is being taken.*) (* If we are not translating a callee expression, then the address of the function is being taken.*)
(* As e.g. in fun_ptr = foo; *) (* As e.g. in fun_ptr = foo; *)
@ -314,7 +314,7 @@ struct
(!CFrontend_config.language = CFrontend_config.OBJC || (!CFrontend_config.language = CFrontend_config.OBJC ||
!CFrontend_config.language = CFrontend_config.OBJCPP) then !CFrontend_config.language = CFrontend_config.OBJCPP) then
SymExec.ModelBuiltins.malloc_no_fail SymExec.ModelBuiltins.malloc_no_fail
else Procname.from_string name in else Procname.from_string_c_fun name in
let is_builtin = SymExec.function_is_builtin non_mangled_func_name in let is_builtin = SymExec.function_is_builtin non_mangled_func_name in
if is_builtin then (* malloc, free, exit, scanf, ... *) if is_builtin then (* malloc, free, exit, scanf, ... *)
{ empty_res_trans with exps = [(Sil.Const (Sil.Cfun non_mangled_func_name), typ)]} { empty_res_trans with exps = [(Sil.Const (Sil.Cfun non_mangled_func_name), typ)]}

@ -630,7 +630,7 @@ let method_invocation context loc pc var_opt cn ms sil_obj_opt expr_list invoke_
init init
expr_list in expr_list in
let callee_procname = let callee_procname =
let proc = Procname.from_string (JBasics.ms_name ms) in let proc = Procname.from_string_c_fun (JBasics.ms_name ms) in
if JBasics.cn_equal cn JConfig.infer_builtins_cl && SymExec.function_is_builtin proc then proc if JBasics.cn_equal cn JConfig.infer_builtins_cl && SymExec.function_is_builtin proc then proc
else Cfg.Procdesc.get_proc_name callee_procdesc in else Cfg.Procdesc.get_proc_name callee_procdesc in
let call_idl, call_instrs = let call_idl, call_instrs =

Loading…
Cancel
Save