diff --git a/.inferconfig b/.inferconfig index b4e598b9e..f6e6fcb94 100644 --- a/.inferconfig +++ b/.inferconfig @@ -1,4 +1,5 @@ { + "force-delete-results-dir": true, "siof-safe-methods": ["getGlobalNonPODWhitelisted", "whitelisted::getGlobalNonPOD", "whitelisted::TemplatedObject::getGlobalNonPOD"], "skip-translation": [ diff --git a/infer/src/backend/infer.ml b/infer/src/backend/infer.ml index af3e62b27..e852db474 100644 --- a/infer/src/backend/infer.ml +++ b/infer/src/backend/infer.ml @@ -52,10 +52,11 @@ let remove_results_dir () = (* Look if file exists, it may not be a directory but that will be caught by the call to [is_results_dir]. If it's an empty directory, leave it alone. This allows users to create a temporary directory for the infer results without infer removing it to recreate it, which could be racy. *) if Sys.file_exists Config.results_dir = `Yes && not (Utils.directory_is_empty Config.results_dir) then ( - Result.iter_error (is_results_dir ()) ~f:(fun err -> - L.(die UserError) - "ERROR: '%s' exists but does not seem to be an infer results directory: %s@\nERROR: Please delete '%s' and try again@." - Config.results_dir err Config.results_dir ) ; + if not Config.force_delete_results_dir then + Result.iter_error (is_results_dir ()) ~f:(fun err -> + L.(die UserError) + "ERROR: '%s' exists but does not seem to be an infer results directory: %s@\nERROR: Please delete '%s' and try again@." + Config.results_dir err Config.results_dir ) ; Utils.rmtree Config.results_dir ) let setup_results_dir () = diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index c0200270e..e48aff934 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -1106,6 +1106,16 @@ and flavors = ~in_help:CLOpt.([(Capture, manual_buck_flavors)]) "Buck integration using Buck flavors (clang only), eg $(i,`infer --flavors -- buck build //foo:bar#infer`)" +and force_delete_results_dir = + CLOpt.mk_bool ~long:"force-delete-results-dir" ~default:false + ~in_help: + (CLOpt.( + [ (Capture, manual_generic) + ; (Compile, manual_generic) + ; (Diff, manual_generic) + ; (Run, manual_generic) ])) + "Do not refuse to delete the results directory if it doesn't look like an infer results directory." + and from_json_report = CLOpt.mk_path_opt ~long:"from-json-report" ~in_help:CLOpt.([(Report, manual_generic)]) @@ -2067,6 +2077,8 @@ and filtering = !filtering and flavors = !flavors +and force_delete_results_dir = !force_delete_results_dir + and fragment_retains_view = !fragment_retains_view and from_json_report = !from_json_report diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 990bfc79d..73335260b 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -404,6 +404,8 @@ val filtering : bool val flavors : bool +val force_delete_results_dir : bool + val fragment_retains_view : bool val from_json_report : string option diff --git a/infer/tests/build_systems/ant/.inferconfig b/infer/tests/build_systems/ant/.inferconfig index 90264e7cb..a553feb67 100644 --- a/infer/tests/build_systems/ant/.inferconfig +++ b/infer/tests/build_systems/ant/.inferconfig @@ -1,4 +1,5 @@ { + "force-delete-results-dir": true, "skip-translation": [ { "language": "Java", diff --git a/infer/tests/codetoanalyze/cpp/quandary/.inferconfig b/infer/tests/codetoanalyze/cpp/quandary/.inferconfig index 2fdde237a..b434de8ee 100644 --- a/infer/tests/codetoanalyze/cpp/quandary/.inferconfig +++ b/infer/tests/codetoanalyze/cpp/quandary/.inferconfig @@ -1,4 +1,5 @@ { + "force-delete-results-dir": true, "quandary-sources": [ { "procedure": "__infer_taint_source", diff --git a/infer/tests/codetoanalyze/java/.inferconfig b/infer/tests/codetoanalyze/java/.inferconfig index 6d1e0898c..3613e92e3 100644 --- a/infer/tests/codetoanalyze/java/.inferconfig +++ b/infer/tests/codetoanalyze/java/.inferconfig @@ -1,4 +1,5 @@ { + "force-delete-results-dir": true, "never-returning-null": [ { "language": "Java", diff --git a/infer/tests/codetoanalyze/java/checkers/.inferconfig b/infer/tests/codetoanalyze/java/checkers/.inferconfig index 15e60379b..5d7cc8d97 100644 --- a/infer/tests/codetoanalyze/java/checkers/.inferconfig +++ b/infer/tests/codetoanalyze/java/checkers/.inferconfig @@ -1,4 +1,5 @@ { + "force-delete-results-dir": true, "modeled-expensive": [ { "language": "Java", diff --git a/infer/tests/codetoanalyze/java/infer/.inferconfig b/infer/tests/codetoanalyze/java/infer/.inferconfig index 07907b1fb..dc3c086c7 100644 --- a/infer/tests/codetoanalyze/java/infer/.inferconfig +++ b/infer/tests/codetoanalyze/java/infer/.inferconfig @@ -1,4 +1,5 @@ { + "force-delete-results-dir": true, "never-returning-null": [ { "language": "Java", diff --git a/infer/tests/codetoanalyze/java/quandary/.inferconfig b/infer/tests/codetoanalyze/java/quandary/.inferconfig index f4bd3a13f..927113ef2 100644 --- a/infer/tests/codetoanalyze/java/quandary/.inferconfig +++ b/infer/tests/codetoanalyze/java/quandary/.inferconfig @@ -1,4 +1,5 @@ { + "force-delete-results-dir": true, "quandary-sources": [ { "procedure": "codetoanalyze.java.quandary.ExternalSpecs.privateData*", diff --git a/infer/tests/codetoanalyze/java/threadsafety/.inferconfig b/infer/tests/codetoanalyze/java/threadsafety/.inferconfig index c60f430a4..ad61ed582 100644 --- a/infer/tests/codetoanalyze/java/threadsafety/.inferconfig +++ b/infer/tests/codetoanalyze/java/threadsafety/.inferconfig @@ -1,4 +1,5 @@ { + "force-delete-results-dir": true, "threadsafe-aliases": ["MyThreadSafeAlias1", "codetoanalyze.java.checkers.MyThreadSafeAlias2"], "skip-translation": [ { diff --git a/infer/tests/codetoanalyze/java/tracing/.inferconfig b/infer/tests/codetoanalyze/java/tracing/.inferconfig index 07907b1fb..dc3c086c7 100644 --- a/infer/tests/codetoanalyze/java/tracing/.inferconfig +++ b/infer/tests/codetoanalyze/java/tracing/.inferconfig @@ -1,4 +1,5 @@ { + "force-delete-results-dir": true, "never-returning-null": [ { "language": "Java",