Blacklist translation of files in inferconfig

Summary:
Now we can add to inferconfig an option
skip-translation-file to skip completely the translation
and analysis of some file.

Reviewed By: jberdine

Differential Revision: D3311129

fbshipit-source-id: 58fd179
master
Dulma Churchill 9 years ago committed by Facebook Github Bot 7
parent 45984d7337
commit 83e6ab1a20

@ -416,3 +416,6 @@ let test () =
let skip_translation_headers = let skip_translation_headers =
lazy (lookup_string_list "skip_translation_headers" (Lazy.force Config.inferconfig_json)) lazy (lookup_string_list "skip_translation_headers" (Lazy.force Config.inferconfig_json))
let skip_clang_analysis_in_path =
lazy (lookup_string_list "skip-clang-analysis-in-path" (Lazy.force Config.inferconfig_json))

@ -52,6 +52,8 @@ val test: unit -> unit
val skip_translation_headers : string list Lazy.t val skip_translation_headers : string list Lazy.t
val skip_clang_analysis_in_path : string list Lazy.t
(** is_checker_enabled [error_name] is [true] if [error_name] is whitelisted in .inferconfig or if (** is_checker_enabled [error_name] is [true] if [error_name] is whitelisted in .inferconfig or if
it's enabled by default *) it's enabled by default *)
val is_checker_enabled : string -> bool val is_checker_enabled : string -> bool

@ -131,6 +131,14 @@ let should_translate_lib source_range decl_trans_context =
not Config.no_translate_libs not Config.no_translate_libs
|| should_translate source_range decl_trans_context || should_translate source_range decl_trans_context
let is_file_blacklisted file =
let paths = Lazy.force Inferconfig.skip_clang_analysis_in_path in
let is_file_blacklisted =
IList.exists
(fun path -> Str.string_match (Str.regexp ("^.*/" ^ path)) file 0)
paths in
is_file_blacklisted
let get_sil_location_from_range source_range prefer_first = let get_sil_location_from_range source_range prefer_first =
let sloc1, sloc2 = source_range in let sloc1, sloc2 = source_range in
let sloc = if not prefer_first then sloc2 else choose_sloc sloc1 sloc2 in let sloc = if not prefer_first then sloc2 else choose_sloc sloc1 sloc2 in
@ -142,10 +150,7 @@ let get_sil_location stmt_info context =
clang_to_sil_location sloc (Some (CContext.get_procdesc context)) clang_to_sil_location sloc (Some (CContext.get_procdesc context))
let check_source_file source_file = let check_source_file source_file =
let extensions_allowed = [".m"; ".mm"; ".c"; ".cc"; ".cpp"; ".h"] in if is_file_blacklisted source_file then
let allowed = IList.exists (fun ext -> Filename.check_suffix source_file ext) extensions_allowed in
if not allowed then
(Printing.log_stats "%s" (Printing.log_stats "%s"
("\nThe source file "^source_file^ ("\n Skip the analysis of source file" ^ source_file ^ "\n\n");
" should end with "^(IList.to_string (fun x -> x) extensions_allowed)^"\n\n"); exit(0));
assert false)

Loading…
Cancel
Save