diff --git a/infer/lib/python/infer b/infer/lib/python/infer index 81b34f5b7..1bb87f0ee 100755 --- a/infer/lib/python/infer +++ b/infer/lib/python/infer @@ -121,6 +121,7 @@ def main(): if imported_module: analyze.create_results_dir(args.infer_out) + analyze.reset_start_file(args.infer_out) utils.configure_logging(args) logging.info('Running command %s', ' '.join(sys.argv)) diff --git a/infer/lib/python/inferlib/analyze.py b/infer/lib/python/inferlib/analyze.py index 489cf910e..9152be3f8 100644 --- a/infer/lib/python/inferlib/analyze.py +++ b/infer/lib/python/inferlib/analyze.py @@ -198,6 +198,11 @@ def create_results_dir(results_dir): utils.mkdir_if_not_exists(os.path.join(results_dir, 'sources')) +def reset_start_file(results_dir): + # create new empty file - this will update modified timestamp + open(os.path.join(results_dir, '.start'), 'w').close() + + def clean(infer_out): directories = ['multicore', 'classnames', 'sources', jwlib.FILELISTS] extensions = ['.cfg', '.cg'] diff --git a/infer/src/backend/DB.ml b/infer/src/backend/DB.ml index b5ceb22da..3185dadae 100644 --- a/infer/src/backend/DB.ml +++ b/infer/src/backend/DB.ml @@ -332,3 +332,15 @@ let is_source_file path = IList.exists (fun ext -> Filename.check_suffix path ext) Config.source_file_extentions + +let infer_start_time = lazy + (file_modified_time (Results_dir.path_to_filename Results_dir.Abs_root [Config.start_filename])) + +(** Return whether filename was updated after analysis started. File doesn't have to exist *) +let file_was_updated_after_start fname = + if file_exists fname then + let file_mtime = file_modified_time fname in + file_mtime >= Lazy.force infer_start_time + else + (* since file doesn't exist, it wasn't modified *) + false diff --git a/infer/src/backend/DB.mli b/infer/src/backend/DB.mli index 4aa754986..ff305f204 100644 --- a/infer/src/backend/DB.mli +++ b/infer/src/backend/DB.mli @@ -27,6 +27,8 @@ val filename_add_suffix : filename -> string -> filename val file_exists : filename -> bool val file_remove : filename -> unit val file_modified_time : filename -> float (** Return the time when a file was last modified. The file must exist. *) +(** Return whether filename was updated after analysis started. File doesn't have to exist *) +val file_was_updated_after_start : filename -> bool (** {2 Results Directory} *) diff --git a/infer/src/backend/config.ml b/infer/src/backend/config.ml index 12e0828c2..cedb7daf9 100644 --- a/infer/src/backend/config.ml +++ b/infer/src/backend/config.ml @@ -396,6 +396,8 @@ let weak = "<\"Weak\">" let assign = "<\"Assign\">" +let start_filename = ".start" + (** Programming language. *) type language = C_CPP | Java