|
|
|
@ -49,3 +49,25 @@ let store_attributes proc_attributes =
|
|
|
|
|
let load_attributes proc_name =
|
|
|
|
|
let attributes_file = res_dir_attr_filename proc_name in
|
|
|
|
|
Serialization.from_file serializer attributes_file
|
|
|
|
|
|
|
|
|
|
(** Given a procdesure name, find the file where it is defined and *)
|
|
|
|
|
(** its corresponding type environment *)
|
|
|
|
|
let find_tenv_from_class_of_proc procname =
|
|
|
|
|
match load_attributes procname with
|
|
|
|
|
| None -> None
|
|
|
|
|
| Some attrs ->
|
|
|
|
|
let source_file = attrs.ProcAttributes.loc.Location.file in
|
|
|
|
|
let source_dir = DB.source_dir_from_source_file source_file in
|
|
|
|
|
let tenv_fname = DB.source_dir_get_internal_file source_dir ".tenv" in
|
|
|
|
|
Tenv.load_from_file tenv_fname
|
|
|
|
|
|
|
|
|
|
(** Given an ObjC class c, extract the type from the tenv where the class was *)
|
|
|
|
|
(** defined. We do this by adding a method that is unique to each class, and then *)
|
|
|
|
|
(** finding the tenv that corresponds to the class definition. *)
|
|
|
|
|
let get_correct_type_from_objc_class_name c =
|
|
|
|
|
let class_method = Procname.get_default_objc_class_method (Mangled.to_string c) in
|
|
|
|
|
match find_tenv_from_class_of_proc class_method with
|
|
|
|
|
| None -> None
|
|
|
|
|
| Some tenv ->
|
|
|
|
|
let type_name = Typename.TN_csu (Csu.Class Csu.Objc, c) in
|
|
|
|
|
Option.map (fun st -> Sil.Tstruct st) (Tenv.lookup tenv type_name)
|
|
|
|
|