From a62c71290b4f03db93277fe8abc01911631277c0 Mon Sep 17 00:00:00 2001 From: jrm Date: Thu, 27 Aug 2015 11:37:49 -0700 Subject: [PATCH] [infer] Change the error message when the project root is not a prefix of the absolute path of the source files Summary: More verbose error in the case where the project root is not a prefix of the source file path --- infer/src/backend/DB.ml | 4 +--- infer/src/backend/DB.mli | 2 -- infer/src/clang/cLocation.ml | 4 +++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/infer/src/backend/DB.ml b/infer/src/backend/DB.ml index be0721f44..8593b1154 100644 --- a/infer/src/backend/DB.ml +++ b/infer/src/backend/DB.ml @@ -16,8 +16,6 @@ module L = Logging (** {2 Source Files} *) -exception Path_not_prefix_root - type source_file = | Absolute of string | Relative of string @@ -51,7 +49,7 @@ let rel_source_file_from_abs_path root fname = if Utils.string_is_prefix root fname then let relative_fname = filename_to_relative root fname in Relative relative_fname - else raise Path_not_prefix_root + else failwith ("The project root " ^ root ^ " is not a prefix of " ^ fname) (** convert a path to a source file, turning it into an absolute path if necessary *) let abs_source_file_from_path fname = diff --git a/infer/src/backend/DB.mli b/infer/src/backend/DB.mli index dad9c3bdd..23c0b8581 100644 --- a/infer/src/backend/DB.mli +++ b/infer/src/backend/DB.mli @@ -60,8 +60,6 @@ end type source_file -exception Path_not_prefix_root - (** Maps from source_file *) module SourceFileMap : Map.S with type key = source_file diff --git a/infer/src/clang/cLocation.ml b/infer/src/clang/cLocation.ml index c2ac8a91b..72ed6d3d6 100644 --- a/infer/src/clang/cLocation.ml +++ b/infer/src/clang/cLocation.ml @@ -33,7 +33,9 @@ let source_file_from_path path = | Some root -> (try DB.rel_source_file_from_abs_path root path - with DB.Path_not_prefix_root -> + with Failure _ -> + Logging.out + "ERROR: %s should be a prefix of %s.@." root path; DB.source_file_from_string path) | None -> DB.source_file_from_string path