diff --git a/infer/src/backend/inferconfig.ml b/infer/src/backend/inferconfig.ml index e7109f16b..c10411c4d 100644 --- a/infer/src/backend/inferconfig.ml +++ b/infer/src/backend/inferconfig.ml @@ -414,3 +414,12 @@ let test () = (DB.source_file_to_rel_path source_file) matching_s) (Sys.getcwd ()) + +let skip_translation_headers = + lazy ( + match + lookup_string_list "skip_translation_headers" + (Yojson.Basic.from_file (inferconfig ())) + with + | exception _ -> [] + | headers -> headers) diff --git a/infer/src/backend/inferconfig.mli b/infer/src/backend/inferconfig.mli index 0aafeae2e..24378b1a7 100644 --- a/infer/src/backend/inferconfig.mli +++ b/infer/src/backend/inferconfig.mli @@ -52,3 +52,5 @@ end (** Load the config file and list the files to report on *) val test: unit -> unit + +val skip_translation_headers : string list Lazy.t diff --git a/infer/src/clang/cLocation.ml b/infer/src/clang/cLocation.ml index 1ccfa9fc6..8a7a2622c 100644 --- a/infer/src/clang/cLocation.ml +++ b/infer/src/clang/cLocation.ml @@ -76,8 +76,16 @@ let clang_to_sil_location clang_loc procdesc_opt = | None -> !curr_file, !Config.nLOC in Location.{line; col; file; nLOC} -let file_in_project file = match !Config.project_root with - | Some root -> string_is_prefix root file +let file_in_project file = + match !Config.project_root with + | Some root -> + let file_in_project = string_is_prefix root file in + let paths = Lazy.force Inferconfig.skip_translation_headers in + let file_should_be_skipped = + IList.exists + (fun path -> string_is_prefix (Filename.concat root path) file) + paths in + file_in_project && not (file_should_be_skipped) | None -> false let should_do_frontend_check (loc_start, _) = diff --git a/infer/src/clang/cMain.ml b/infer/src/clang/cMain.ml index 0ae344245..bc21b7a92 100644 --- a/infer/src/clang/cMain.ml +++ b/infer/src/clang/cMain.ml @@ -88,6 +88,10 @@ let arg_desc = None, "Analyze C++ methods, still experimental" ; + "-inferconfig_home", + Arg.String (fun s -> Config.inferconfig_home := Some s), + Some "dir", + "Path to the .inferconfig file"; ] in Arg.create_options_desc false "Parsing Options" desc @@ -137,6 +141,9 @@ let do_run source_path ast_path = CFrontend_config.json := ast_filename; CLocation.check_source_file source_path; let source_file = CLocation.source_file_from_path source_path in + (match !Config.inferconfig_home with + | Some _ -> () + | None -> Config.inferconfig_home := !Config.project_root); Printf.printf "Start translation of AST from %s\n" !CFrontend_config.json; CFrontend.do_source_file source_file ast_decl; Printf.printf "End translation AST file %s... OK!\n" !CFrontend_config.json;