From 2e27c5127bf96451ef88aa37b1cd5b1140a659cc Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Wed, 26 Aug 2015 10:00:42 -0600 Subject: [PATCH] [Infer][frontend] Making -incremental-changed-only option available from command line Summary: About to add some tests for this and need to be able to turn it on. --- infer/bin/inferlib.py | 23 ++++++++++++++++++++--- infer/src/backend/inferanalyze.ml | 2 +- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/infer/bin/inferlib.py b/infer/bin/inferlib.py index cefac165d..b73ae241f 100644 --- a/infer/bin/inferlib.py +++ b/infer/bin/inferlib.py @@ -69,6 +69,16 @@ class VersionAction(argparse._VersionAction): option_string) +class ConfirmIncrementalAction(argparse._StoreTrueAction): + def __call__(self, parser, namespace, values, option_string=None): + if not getattr(namespace, 'incremental'): + parser.error('-ic/--changed-only should only be used with -i') + super(ConfirmIncrementalAction, self).__call__(parser, + namespace, + values, + option_string) + + base_parser = argparse.ArgumentParser(add_help=False) base_group = base_parser.add_argument_group('global arguments') base_group.add_argument('-o', '--out', metavar='', @@ -76,8 +86,12 @@ base_group.add_argument('-o', '--out', metavar='', action=utils.AbsolutePathAction, help='Set the Infer results directory') base_group.add_argument('-i', '--incremental', action='store_true', - help='''Do not delete the results directory across - Infer runs''') + help='''Analyze only changed procedures and their + dependencies''') +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('-g', '--debug', action='store_true', help='Generate extra debugging information') base_group.add_argument('-a', '--analyzer', @@ -498,7 +512,10 @@ class Infer: ] if self.args.incremental: - infer_options.append('-incremental') + if self.args.changed_only: + infer_options.append('-incremental_changed_only') + else: + infer_options.append('-incremental') if self.args.specs_dirs: infer_options += self.args.specs_dirs diff --git a/infer/src/backend/inferanalyze.ml b/infer/src/backend/inferanalyze.ml index 1d0b240b5..5cfcd5d7e 100644 --- a/infer/src/backend/inferanalyze.ml +++ b/infer/src/backend/inferanalyze.ml @@ -136,7 +136,7 @@ let arg_desc = [ "-err_file", Arg.Set_string err_file_cmdline, Some "file", "use file for the err channel"; "-exclude", Arg.String exclude, Some "file", "exclude from analysis the files and directories specified in file"; - "-incremental_ignore_dependencies", Arg.Unit (fun () -> incremental_mode := ANALYZE_CHANGED_ONLY), None, "only analyze files captured since the last analysis"; + "-incremental_changed_only", Arg.Unit (fun () -> incremental_mode := ANALYZE_CHANGED_ONLY), None, "only analyze files captured since the last analysis"; "-incremental", Arg.Unit (fun () -> incremental_mode := ANALYZE_CHANGED_AND_DEPENDENCIES), None, "analyze files captured since the last analysis plus any dependencies"; "-iterations", Arg.Set_int iterations_cmdline, Some "n", "set the max number of operations for each function, expressed as a multiple of symbolic operations (default n=1)"; "-nonstop", Arg.Set Config.nonstop, None, "activate the nonstop mode: the analysis continues after finding errors. With this option the analysis can become less precise.";