idirafter override flag

Reviewed By: ngorogiannis

Differential Revision: D16732511

fbshipit-source-id: 6a554f7e1
master
Martin Trojer 5 years ago committed by Facebook Github Bot
parent 2151a54345
commit 06d6363710

@ -1190,6 +1190,18 @@ INTERNAL OPTIONS
--clang-blacklisted-flags-with-arg-reset
Set --clang-blacklisted-flags-with-arg to the empty list.
--clang-idirafter-to-override-regex 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 regular expression with the path to those
headers so that infer can use its own clang internal headers
instead. Concretely, this will replace -idirafter <path matching
the regex> with -idirafter
/path/to/infer/facebook-clang-plugins/clang/install/lib/clang/<version>/include.
--clang-idirafter-to-override-regex-reset
Cancel the effect of --clang-idirafter-to-override-regex.
--clang-ignore-regex dir_OCaml_regex
The files in this regex will be ignored in the compilation process
and an empty file will be passed to clang instead. This is to be

@ -1006,6 +1006,15 @@ and clang_ignore_regex =
around missing generated files."
and clang_idirafter_to_override_regex =
CLOpt.mk_string_opt ~long:"clang-idirafter-to-override-regex" ~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 regular expression with \
the path to those headers so that infer can use its own clang internal headers instead. \
Concretely, this will replace $(b,-idirafter <path matching the regex>) with $(b,-idirafter \
/path/to/infer/facebook-clang-plugins/clang/install/lib/clang/<version>/include)."
and clang_isystem_to_override_regex =
CLOpt.mk_string_opt ~long:"clang-isystem-to-override-regex"
~deprecated:["-clang-include-to-override-regex"; "-clang-include-to-override"]
@ -2755,7 +2764,9 @@ and clang_blacklisted_flags_with_arg = !clang_blacklisted_flags_with_arg
and clang_ignore_regex = !clang_ignore_regex
and clang_isystem_to_override_regex = !clang_isystem_to_override_regex
and clang_idirafter_to_override_regex = Option.map ~f:Str.regexp !clang_idirafter_to_override_regex
and clang_isystem_to_override_regex = Option.map ~f:Str.regexp !clang_isystem_to_override_regex
and clang_libcxx_include_to_override_regex = !clang_libcxx_include_to_override_regex

@ -288,7 +288,9 @@ val clang_frontend_action_string : string
val clang_ignore_regex : string option
val clang_isystem_to_override_regex : string option
val clang_isystem_to_override_regex : Str.regexp option
val clang_idirafter_to_override_regex : Str.regexp option
val clang_libcxx_include_to_override_regex : string option

@ -76,8 +76,6 @@ let file_arg_cmd_sanitizer cmd =
{cmd with argv= [Format.sprintf "@%s" file]}
let isystem_to_override_regex = Option.map ~f:Str.regexp Config.clang_isystem_to_override_regex
let libcxx_include_to_override_regex =
Option.map ~f:Str.regexp Config.clang_libcxx_include_to_override_regex
@ -148,6 +146,12 @@ let filter_and_replace_unsupported_args ?(replace_options_arg = fun _ s -> s) ?(
of clang with a different version. Also mitigate version discrepancies in clang's
fatal warnings. *)
let clang_cc1_cmd_sanitizer cmd =
let replace_args arg = function
| Some override_regex when Str.string_match override_regex arg 0 ->
fcp_dir ^/ "clang" ^/ "install" ^/ "lib" ^/ "clang" ^/ "8.0.0" ^/ "include"
| _ ->
arg
in
(* command line options not supported by the opensource compiler or the plugins *)
let replace_options_arg options arg =
match (options, arg) with
@ -162,12 +166,10 @@ let clang_cc1_cmd_sanitizer cmd =
| "-dependency-file" :: _, _ when Option.is_some Config.buck_compilation_database ->
(* In compilation database mode, dependency files are not assumed to exist *)
"/dev/null"
| "-isystem" :: _, arg -> (
match isystem_to_override_regex with
| Some isystem_to_override_regex when Str.string_match isystem_to_override_regex arg 0 ->
fcp_dir ^/ "clang" ^/ "install" ^/ "lib" ^/ "clang" ^/ "8.0.0" ^/ "include"
| _ ->
arg )
| "-idirafter" :: _, arg ->
replace_args arg Config.clang_idirafter_to_override_regex
| "-isystem" :: _, arg ->
replace_args arg Config.clang_isystem_to_override_regex
| "-I" :: _, arg -> (
match libcxx_include_to_override_regex with
| Some libcxx_include_to_override_regex

Loading…
Cancel
Save