From d5fbb298ebcbb4da890a4b55e646f40fa2b0a840 Mon Sep 17 00:00:00 2001 From: Martino Luca Date: Wed, 24 May 2017 11:05:14 -0700 Subject: [PATCH] Skip compilation of certain source files, if desired Summary: All files that match the regular-expressions passed via `--skip-analysis-in-path` are just compiled. With this change, you can also opt for not compiling those files at all, by passing the `--skip-analysis-in-path-skips-compilation` argument Reviewed By: mbouaziz Differential Revision: D5121583 fbshipit-source-id: 4e1325a --- infer/src/base/Config.ml | 7 +++++++ infer/src/base/Config.mli | 1 + infer/src/clang/Capture.re | 7 ++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 15a03df0b..465125007 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -1348,6 +1348,12 @@ and skip_analysis_in_path = ~meta:"path prefix OCaml regex" "Ignore files whose path matches the given prefix (can be specified multiple times)" +and skip_analysis_in_path_skips_compilation = + CLOpt.mk_bool ~long:"skip-analysis-in-path-skips-compilation" + ~in_help:CLOpt.[Report, manual_generic] + ~default:false + "Whether paths in --skip-analysis-in-path should be compiled or not" + and skip_duplicated_types = CLOpt.mk_bool ~long:"skip-duplicated-types" ~default:true ~in_help:CLOpt.[ReportDiff, manual_generic] @@ -1851,6 +1857,7 @@ and show_progress_bar = !progress_bar and siof = !siof and siof_safe_methods = !siof_safe_methods and skip_analysis_in_path = !skip_analysis_in_path +and skip_analysis_in_path_skips_compilation = !skip_analysis_in_path_skips_compilation and skip_duplicated_types = !skip_duplicated_types and skip_translation_headers = !skip_translation_headers and sources = !sources diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 305fb3835..405ce3db4 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -321,6 +321,7 @@ val show_progress_bar : bool val siof : bool val siof_safe_methods : string list val skip_analysis_in_path : string list +val skip_analysis_in_path_skips_compilation : bool val skip_duplicated_types : bool val skip_translation_headers : string list val spec_abs_level : int diff --git a/infer/src/clang/Capture.re b/infer/src/clang/Capture.re index 52c7651ef..f722623d2 100644 --- a/infer/src/clang/Capture.re +++ b/infer/src/clang/Capture.re @@ -166,11 +166,16 @@ let cc1_capture clang_cmd => { Logging.out "@\n*** Beginning capture of file %s ***@\n" source_path; if ( Config.equal_analyzer Config.analyzer Config.CompileOnly || - CLocation.is_file_blacklisted source_path + not Config.skip_analysis_in_path_skips_compilation && CLocation.is_file_blacklisted source_path ) { Logging.out "@\n Skip the analysis of source file %s@\n@\n" source_path; /* We still need to run clang, but we don't have to attach the plugin. */ run_clang (ClangCommand.command_to_run clang_cmd) Utils.consume_in + } else if ( + Config.skip_analysis_in_path_skips_compilation && CLocation.is_file_blacklisted source_path + ) { + Logging.out "@\n Skip compilation and analysis of source file %s@\n@\n" source_path; + () } else { switch Config.clang_biniou_file { | Some fname => run_and_validate_clang_frontend (`File fname)