[Infer][backend] No longer crashing when -project_root is not a prefix of source file path

Summary:
Some build systems compile files both under the project root and under temporary
directories (e.g., /tmp), so there need not be a single project root. Just use absolute paths
in the case that we can't resolve a relative path from the project root.
master
Sam Blackshear 9 years ago
parent f1c5cb337e
commit 5104d852ee

@ -44,16 +44,19 @@ let source_file_from_string path =
else else
Absolute path Absolute path
(** convert a path to a source file, turning it into an absolute path if necessary *)
let abs_source_file_from_path fname =
Absolute (filename_to_absolute fname)
(** convert a project root directory and a full path to a rooted source file *) (** convert a project root directory and a full path to a rooted source file *)
let rel_source_file_from_abs_path root fname = let rel_source_file_from_abs_path root fname =
if Utils.string_is_prefix root fname then if Utils.string_is_prefix root fname then
let relative_fname = filename_to_relative root fname in let relative_fname = filename_to_relative root fname in
Relative relative_fname Relative relative_fname
else failwith ("The project root " ^ root ^ " is not a prefix of " ^ fname) else begin
L.err "The project root %s is not a prefix of %s@." root fname;
(** convert a path to a source file, turning it into an absolute path if necessary *) abs_source_file_from_path fname
let abs_source_file_from_path fname = end
Absolute (filename_to_absolute fname)
type encoding_type = type encoding_type =
Enc_base | Enc_path_with_underscores | Enc_crc Enc_base | Enc_path_with_underscores | Enc_crc

Loading…
Cancel
Save