Add command line arguments for reactive mode.

Summary:public
Add command-line argument --reactive to enable reactive propagation mode.
When the mode is active, the files changed during compilation are detected, and the analysis propagates reactively starting from the modified files.
The reactive mode allows to analyze a subset of the files in a project and follow their dependencies, without storing the results of previous analyses (specs files). Captured files are preserved from previous runs of the analysis (for example, when the previous analysis was the initial capture), so the mode can be used repeatedly while changing code.

Reviewed By: jvillard

Differential Revision: D2931697

fb-gh-sync-id: 9d6dda0
shipit-source-id: 9d6dda0
master
Cristiano Calcagno 9 years ago committed by facebook-github-bot-1
parent 49bf38c56f
commit 42ecddcf37

@ -114,6 +114,7 @@ def main():
remove_infer_out = (imported_module
and not args.incremental
and not args.reactive
and capture_module_name != 'analyze'
and not args.buck)
if remove_infer_out:

@ -75,6 +75,9 @@ base_group.add_argument('-ic', '--changed-only',
action=ConfirmIncrementalAction,
help='''Same as -i, but does not analyze
dependencies of changed procedures.''')
base_group.add_argument('--reactive', action='store_true',
help='''Analyze in reactive propagation mode
starting from changed files.''')
base_group.add_argument('--debug-exceptions', action='store_true',
help='''Generate lightweight debugging information:
just print the internal exceptions during analysis''')
@ -418,6 +421,9 @@ class Infer:
else:
infer_options.append('-incremental')
if self.args.reactive:
infer_options.append('-reactive')
if self.args.specs_dirs:
infer_options += self.args.specs_dirs

@ -30,12 +30,29 @@ let pp_prolog fmt clusters =
begin
match Cluster.get_ondemand_info ce with
| Some source_dir ->
let in_ondemand_config = match Ondemand.read_dirs_to_analyze () with
let fname = DB.source_dir_to_string source_dir in
let in_ondemand_config =
match Ondemand.read_dirs_to_analyze () with
| None ->
true
None
| Some set ->
StringSet.mem (DB.source_dir_to_string source_dir) set in
in_ondemand_config
Some (StringSet.mem fname set) in
let check_modified () =
let modified =
DB.file_was_updated_after_start (DB.filename_from_string fname) in
if modified &&
!Config.developer_mode
then L.stdout "Modified: %s@." fname;
modified in
begin
match in_ondemand_config with
| Some b -> (* ondemand config file is specified *)
b
| None when !Config.reactive_mode ->
check_modified ()
| None ->
true
end
| None ->
true
end

@ -179,9 +179,14 @@ let eradicate = ref false
(** should the checkers be run? *)
let checkers_enabled () = not !eradicate
(** flag to activate ondemand mode. *)
(** flag for ondemand mode:
procedure calls trigger a new analysis if the summary is not present already *)
let ondemand_enabled = ref false
(** flag for reactive mode:
the analysis starts from the files captured since the "infer" command started *)
let reactive_mode = ref false
(** Flag for footprint discovery mode *)
let footprint = ref true

@ -177,6 +177,11 @@ let arg_desc =
None,
"print the builtin functions and exit"
;
"-reactive",
Arg.Unit (fun () -> Config.ondemand_enabled := true; Config.reactive_mode := true),
None,
"analyze in reactive propagation mode starting from changed files"
;
"-source_path",
Arg.String source_path,
Some "path",

Loading…
Cancel
Save