diff --git a/infer/src/backend/DB.ml b/infer/src/backend/DB.ml index 7b5b8064b..c74696fb6 100644 --- a/infer/src/backend/DB.ml +++ b/infer/src/backend/DB.ml @@ -101,6 +101,16 @@ let source_file_encoding source_file = let crc = CRC.crc16 dir in base ^ "." ^ crc +(** covert a long filename to a short ones by truncating the name and adding a hash *) +let get_short_filename filename = + let cutoff_length = 100 in (** if longer than cutoff, cut it and append CRC *) + let name_up_to_cutoff = + if String.length filename <= cutoff_length + then filename + else String.sub filename 0 cutoff_length in + let crc_str = CRC.crc16 filename in + name_up_to_cutoff ^ ":" ^ crc_str + let source_file_empty = Absolute "" (** current source file *) @@ -118,7 +128,8 @@ let source_dir_to_string source_dir = source_dir (** get the path to an internal file with the given extention (.cfg, .cg, .tenv) *) let source_dir_get_internal_file source_dir extension = - let source_dir_name = Filename.chop_extension (Filename.basename source_dir) in + let source_dir_name = + get_short_filename (Filename.chop_extension (Filename.basename source_dir)) in let fname = source_dir_name ^ extension in Filename.concat source_dir fname diff --git a/infer/src/backend/DB.mli b/infer/src/backend/DB.mli index 4aa754986..b0bdcb7f3 100644 --- a/infer/src/backend/DB.mli +++ b/infer/src/backend/DB.mli @@ -126,6 +126,9 @@ val source_dir_from_source_file : source_file -> source_dir (** get the path to the copy of the source file to be stored in the results directory *) val source_file_in_resdir : source_file -> filename +(** covert a long filename to a short ones by truncating the name and adding a hash *) +val get_short_filename : string -> string + (** directory where the results of the capture phase are stored *) val captured_dir : unit -> filename diff --git a/infer/src/backend/procname.ml b/infer/src/backend/procname.ml index ba221ba01..6ff7076d8 100644 --- a/infer/src/backend/procname.ml +++ b/infer/src/backend/procname.ml @@ -449,14 +449,7 @@ let to_simplified_string ?(withclass = false) p = (** Convert a proc name to a filename *) let to_filename (pn : proc_name) = - let cutoff_length = 100 in (** if longer than cutoff, cut it and append CRC *) - let name = to_unique_id pn in - let pname_up_to_cutoff = - if String.length name <= cutoff_length - then name - else String.sub name 0 cutoff_length in - let crc_str = CRC.crc16 name in - pname_up_to_cutoff ^ ":" ^ crc_str + DB.get_short_filename (to_unique_id pn) (** Pretty print a proc name *) let pp f pn =