From 380515bc891bd914bf83c44679e289d489e95082 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Tue, 16 Jul 2019 06:09:09 -0700 Subject: [PATCH] [changed files] don't fail on non-existent absolute paths Summary: When a file is passed to infer through `--changed-files-index` which is - an absolute path - the file does not exist Then the code fails throwing an exception in the function below while trying to relativise the absolute path. The behaviour on relative paths is to skip missing files, and does not fail because Infer does not attempt to relativise them. Swallow the exception and skip the file; and so unify the behaviour across relative and absolute paths. Reviewed By: mityal Differential Revision: D16279672 fbshipit-source-id: 33b468da7 --- infer/src/base/SourceFile.ml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/infer/src/base/SourceFile.ml b/infer/src/base/SourceFile.ml index ffb15c52e..944e18a03 100644 --- a/infer/src/base/SourceFile.ml +++ b/infer/src/base/SourceFile.ml @@ -169,14 +169,16 @@ let create ?(warn_on_error = true) path = let changed_sources_from_changed_files changed_files = List.fold changed_files ~init:Set.empty ~f:(fun changed_files_set line -> - let source_file = create line in - let changed_files' = Set.add source_file changed_files_set in - (* Add source corresponding to changed header if it exists *) - match of_header source_file with - | Some src -> - Set.add src changed_files' - | None -> - changed_files' ) + try + let source_file = create line in + let changed_files' = Set.add source_file changed_files_set in + (* Add source corresponding to changed header if it exists *) + match of_header source_file with + | Some src -> + Set.add src changed_files' + | None -> + changed_files' + with _exn -> changed_files_set ) module SQLite = struct