diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index d8a1d9509..8515d3913 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -641,11 +641,13 @@ and clang_frontend_action = "Specify whether the clang frontend should capture or lint or both." ~symbols:clang_frontend_action_symbols -and clang_include_to_override = - CLOpt.mk_string_opt ~long:"clang-include-to-override" ~meta:"dir" +and clang_include_to_override_regex = + CLOpt.mk_string_opt ~long:"clang-include-to-override-regex" + ~deprecated:["-clang-include-to-override"] + ~meta:"dir OCaml regex" "Use this option in the uncommon case where the normal compilation process overrides the \ - location of internal compiler headers. This option should specify the path to those headers \ - so that infer can use its own clang internal headers instead." + location of internal compiler headers. This option should specify regular expression with \ + the path to those headers so that infer can use its own clang internal headers instead." and classpath = CLOpt.mk_string_opt ~long:"classpath" @@ -1625,7 +1627,7 @@ and dump_duplicate_symbols = !dump_duplicate_symbols and checkers = !checkers and checkers_repeated_calls = !checkers_repeated_calls and clang_biniou_file = !clang_biniou_file -and clang_include_to_override = !clang_include_to_override +and clang_include_to_override_regex = !clang_include_to_override_regex and classpath = !classpath and cluster_cmdline = !cluster and compute_analytics = !compute_analytics diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 4dc6eea09..65a6b0e33 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -197,7 +197,7 @@ val clang_biniou_file : string option val clang_frontend_action_string : string val clang_frontend_do_capture : bool val clang_frontend_do_lint : bool -val clang_include_to_override : string option +val clang_include_to_override_regex : string option val cluster_cmdline : string option val compute_analytics : bool val continue_capture : bool diff --git a/infer/src/clang/ClangCommand.re b/infer/src/clang/ClangCommand.re index 9d76c5332..13c947b22 100644 --- a/infer/src/clang/ClangCommand.re +++ b/infer/src/clang/ClangCommand.re @@ -81,6 +81,8 @@ let file_arg_cmd_sanitizer cmd => { {...cmd, argv: [Format.sprintf "@%s" file]} }; +let include_override_regex = Option.map f::Str.regexp Config.clang_include_to_override_regex; + /* Work around various path or library issues occurring when one tries to substitute Apple's version of clang with a different version. Also mitigate version discrepancies in clang's fatal warnings. */ @@ -105,8 +107,8 @@ let clang_cc1_cmd_sanitizer cmd => { } else if ( String.equal option "-isystem" ) { - switch Config.clang_include_to_override { - | Some to_replace when String.equal arg to_replace => + switch include_override_regex { + | Some regexp when Str.string_match regexp arg 0 => fcp_dir ^\/ "clang" ^\/ "install" ^\/ "lib" ^\/ "clang" ^\/ "4.0.0" ^\/ "include" | _ => arg }