diff --git a/infer/src/base/DB.ml b/infer/src/base/DB.ml index b880dc9c8..66c8d1c4a 100644 --- a/infer/src/base/DB.ml +++ b/infer/src/base/DB.ml @@ -342,6 +342,13 @@ let file_was_updated_after_start fname = (* since file doesn't exist, it wasn't modified *) false +(** Mark a file as updated by changing its timestamps to be one second in the future. + This guarantees that it appears updated after start. *) +let mark_file_updated fname = + let near_future = Unix.gettimeofday () +. 1. in + Unix.utimes fname near_future near_future + + (** Returns true if the file is a C++ model *) let file_is_in_cpp_model file = let normalized_file_dir = filename_to_absolute (Filename.dirname file) in diff --git a/infer/src/base/DB.mli b/infer/src/base/DB.mli index b201c1a3d..679fc1f56 100644 --- a/infer/src/base/DB.mli +++ b/infer/src/base/DB.mli @@ -32,6 +32,10 @@ val file_remove : filename -> unit (** Return the time when a file was last modified. The file must exist. *) val file_modified_time : ?symlink:bool -> filename -> float +(** Mark a file as updated by changing its timestamps to be one second in the future. + This guarantees that it appears updated after start. *) +val mark_file_updated : string -> unit + (** Return whether filename was updated after analysis started. File doesn't have to exist *) val file_was_updated_after_start : filename -> bool diff --git a/infer/src/clang/cFrontend.ml b/infer/src/clang/cFrontend.ml index b46e3e0f6..dee61cf3d 100644 --- a/infer/src/clang/cFrontend.ml +++ b/infer/src/clang/cFrontend.ml @@ -69,4 +69,6 @@ let do_source_file translation_unit_context ast = || Config.testing_mode || Config.frontend_tests then (Dotty.print_icfg_dotty source_file cfg; - Cg.save_call_graph_dotty source_file Specs.get_specs call_graph) + Cg.save_call_graph_dotty source_file Specs.get_specs call_graph); + (* NOTE: nothing should be written to source_dir after this *) + DB.mark_file_updated (DB.source_dir_to_string source_dir) diff --git a/infer/src/java/jMain.ml b/infer/src/java/jMain.ml index 26c2f1b47..a6213d4ed 100644 --- a/infer/src/java/jMain.ml +++ b/infer/src/java/jMain.ml @@ -43,18 +43,18 @@ let init_global_state source_file = let store_icfg source_file tenv cg cfg = let source_dir = DB.source_dir_from_source_file source_file in - begin - let cfg_file = DB.source_dir_get_internal_file source_dir ".cfg" in - let cg_file = DB.source_dir_get_internal_file source_dir ".cg" in - if Config.create_harness then Harness.create_harness cfg cg tenv; - Cg.store_to_file cg_file cg; - Cfg.store_cfg_to_file ~source_file cfg_file cfg; - if Config.debug_mode || Config.frontend_tests then - begin - Dotty.print_icfg_dotty source_file cfg; - Cg.save_call_graph_dotty source_file Specs.get_specs cg - end - end + let cfg_file = DB.source_dir_get_internal_file source_dir ".cfg" in + let cg_file = DB.source_dir_get_internal_file source_dir ".cg" in + if Config.create_harness then Harness.create_harness cfg cg tenv; + Cg.store_to_file cg_file cg; + Cfg.store_cfg_to_file ~source_file cfg_file cfg; + if Config.debug_mode || Config.frontend_tests then + begin + Dotty.print_icfg_dotty source_file cfg; + Cg.save_call_graph_dotty source_file Specs.get_specs cg + end; + (* NOTE: nothing should be written to source_dir after this *) + DB.mark_file_updated (DB.source_dir_to_string source_dir) (* Given a source file, its code is translated, and the call-graph, control-flow-graph and type *)