From 87b29a2d72e0e4c11a209172971b30bdc6f09401 Mon Sep 17 00:00:00 2001 From: Fernando Gasperi Jabalera Date: Mon, 13 Jan 2020 07:36:44 -0800 Subject: [PATCH] Add --scheduler option Reviewed By: ngorogiannis Differential Revision: D19330599 fbshipit-source-id: f185b92ab --- infer/man/man1/infer-full.txt | 3 +++ infer/src/backend/InferAnalyze.ml | 15 ++++++++++----- infer/src/backend/SyntacticCallGraph.ml | 3 +++ infer/src/backend/SyntacticCallGraph.mli | 2 +- infer/src/base/Config.ml | 16 +++++++++++++--- infer/src/base/Config.mli | 4 ++++ 6 files changed, 34 insertions(+), 9 deletions(-) diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index 6d79e1225..ccec92908 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -1690,6 +1690,9 @@ INTERNAL OPTIONS Reset the list of folders containing linters definitions to be empty (see linters-def-folder). + --scheduler { File | SyntacticCallGraph } + Specify the scheduler used for the analysis phase + --scuba-logging Activates: (direct) logging to scuba (Conversely: --no-scuba-logging) diff --git a/infer/src/backend/InferAnalyze.ml b/infer/src/backend/InferAnalyze.ml index bb055f2d1..ceecd9cd1 100644 --- a/infer/src/backend/InferAnalyze.ml +++ b/infer/src/backend/InferAnalyze.ml @@ -11,6 +11,7 @@ open! IStd module F = Format module L = Logging +module CLOpt = CommandLineOption let clear_caches () = Ondemand.LocalCache.clear () ; Summary.OnDisk.clear_cache () ; Procname.SQLite.clear_cache () @@ -113,11 +114,15 @@ let get_source_files_to_analyze ~changed_files = let schedule sources = - if Config.call_graph_schedule then - ProcessPool.TaskGenerator.chain - (SyntacticCallGraph.bottom_up sources) - (FileScheduler.make sources) - else FileScheduler.make sources + if Config.call_graph_schedule then ( + CLOpt.warnf "WARNING: '--call-graph-schedule' is deprecated. Use '--scheduler' instead.@." ; + SyntacticCallGraph.make sources ) + else + match Config.scheduler with + | SyntacticCallGraph -> + SyntacticCallGraph.make sources + | File -> + FileScheduler.make sources let analyze source_files_to_analyze = diff --git a/infer/src/backend/SyntacticCallGraph.ml b/infer/src/backend/SyntacticCallGraph.ml index 47ae197d8..6b1057668 100644 --- a/infer/src/backend/SyntacticCallGraph.ml +++ b/infer/src/backend/SyntacticCallGraph.ml @@ -108,3 +108,6 @@ let bottom_up sources : SchedulerTypes.target ProcessPool.TaskGenerator.t = next_aux () in {remaining_tasks; is_empty; finished; next} + + +let make sources = ProcessPool.TaskGenerator.chain (bottom_up sources) (FileScheduler.make sources) diff --git a/infer/src/backend/SyntacticCallGraph.mli b/infer/src/backend/SyntacticCallGraph.mli index 5c2ffcb73..8903b32ef 100644 --- a/infer/src/backend/SyntacticCallGraph.mli +++ b/infer/src/backend/SyntacticCallGraph.mli @@ -6,7 +6,7 @@ *) open! IStd -val bottom_up : SourceFile.t list -> SchedulerTypes.target ProcessPool.TaskGenerator.t +val make : SourceFile.t list -> SchedulerTypes.target ProcessPool.TaskGenerator.t (** task generator that works by - loading the syntactic call graph from the capture DB diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 005ffbaca..5e5fea107 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -92,6 +92,8 @@ type build_system = | BXcode [@@deriving compare] +type scheduler = File | SyntacticCallGraph [@@deriving equal] + let equal_build_system = [%compare.equal: build_system] (* List of ([build system], [executable name]). Several executables may map to the same build @@ -2353,6 +2355,12 @@ and export_changed_functions_output = "Name of file for export-changed-functions results" +and scheduler = + CLOpt.mk_symbol ~long:"scheduler" ~default:File ~eq:equal_scheduler + ~symbols:[("File", File); ("SyntacticCallGraph", SyntacticCallGraph)] + "Specify the scheduler used for the analysis phase" + + and test_filtering = CLOpt.mk_bool ~deprecated:["test_filtering"] ~long:"test-filtering" "List all the files Infer can report on (should be called from the root of the project)" @@ -3167,14 +3175,16 @@ and resource_leak = !resource_leak and results_dir = !results_dir -and seconds_per_iteration = !seconds_per_iteration - -and select = !select +and scheduler = !scheduler and scuba_logging = !scuba_logging and scuba_normals = !scuba_normals +and seconds_per_iteration = !seconds_per_iteration + +and select = !select + and show_buckets = !print_buckets and siof = !siof diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 53463c767..68a553938 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -25,6 +25,8 @@ type build_system = | BNdk | BXcode +type scheduler = File | SyntacticCallGraph [@@deriving equal] + val equal_build_system : build_system -> build_system -> bool val build_system_of_exe_name : string -> build_system @@ -604,6 +606,8 @@ val rest : string list val results_dir : string +val scheduler : scheduler + val scuba_logging : bool val scuba_normals : string String.Map.t