From b2cef3e0b252c8e5d9ae0db862465c9a65c3c64f Mon Sep 17 00:00:00 2001 From: Andrzej Kotulski Date: Mon, 21 Nov 2016 11:01:27 -0800 Subject: [PATCH] [DB] Alawys use DB.source_file_to_abs_path to do actual filesystem operations Summary: Using DB.source_file_to_string may return relative path which may or may not be relative to current location. I went through all calls to `DB.source_file_to_string` and fixed ones that used that output to open files Reviewed By: jeremydubreil Differential Revision: D4205407 fbshipit-source-id: b285b7e --- infer/src/backend/inferconfig.ml | 2 +- infer/src/backend/printer.ml | 2 +- infer/src/harness/inhabit.ml | 2 +- infer/src/java/jClasspath.ml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/infer/src/backend/inferconfig.ml b/infer/src/backend/inferconfig.ml index 9ffe8407d..195aae383 100644 --- a/infer/src/backend/inferconfig.ml +++ b/infer/src/backend/inferconfig.ml @@ -85,7 +85,7 @@ module FileContainsStringMatcher = struct DB.SourceFileMap.find source_file !source_map with Not_found -> try - let file_in = open_in (DB.source_file_to_string source_file) in + let file_in = open_in (DB.source_file_to_abs_path source_file) in let pattern_found = file_contains regexp file_in in close_in file_in; source_map := DB.SourceFileMap.add source_file pattern_found !source_map; diff --git a/infer/src/backend/printer.ml b/infer/src/backend/printer.ml index 950f7aa3c..03de9c0f3 100644 --- a/infer/src/backend/printer.ml +++ b/infer/src/backend/printer.ml @@ -48,7 +48,7 @@ struct Some (Hashtbl.find hash fname) with Not_found -> try - let lines_arr = read_file (DB.source_file_to_string fname) in + let lines_arr = read_file (DB.source_file_to_abs_path fname) in Hashtbl.add hash fname lines_arr; Some lines_arr with exn when SymOp.exn_not_failure exn -> None diff --git a/infer/src/harness/inhabit.ml b/infer/src/harness/inhabit.ml index 4a6c6cdc6..5b2083728 100644 --- a/infer/src/harness/inhabit.ml +++ b/infer/src/harness/inhabit.ml @@ -217,7 +217,7 @@ let create_dummy_harness_file harness_name = (* TODO (t3040429): fill this file up with Java-like code that matches the SIL *) let write_harness_to_file harness_instrs harness_file = let harness_file = - let harness_file_name = DB.source_file_to_string harness_file in + let harness_file_name = DB.source_file_to_abs_path harness_file in create_outfile harness_file_name in let pp_harness fmt = IList.iter (fun instr -> Format.fprintf fmt "%a\n" (Sil.pp_instr pe_text) instr) harness_instrs in diff --git a/infer/src/java/jClasspath.ml b/infer/src/java/jClasspath.ml index a76e66189..e00d0fe14 100644 --- a/infer/src/java/jClasspath.ml +++ b/infer/src/java/jClasspath.ml @@ -103,7 +103,7 @@ type file_entry = (* Open the source file and search for the package declaration. Only the case where the package is declared in a single line is supported *) let read_package_declaration source_file = - let path = DB.source_file_to_string source_file in + let path = DB.source_file_to_abs_path source_file in let file_in = open_in path in let remove_trailing_semicolon = Str.replace_first (Str.regexp ";") "" in