|
|
|
@ -94,13 +94,17 @@ let normalize ~prog ~args : action_item list =
|
|
|
|
|
(* commands generated by `clang -### ...` start with ' "/absolute/path/to/binary"' *)
|
|
|
|
|
Str.regexp " \"/\\|clang[^ :]*: \\(error\\|warning\\): "
|
|
|
|
|
in
|
|
|
|
|
let ignored_errors =
|
|
|
|
|
Str.regexp "clang[^ :]*: \\(error\\|warning\\): unsupported argument .* to option 'fsanitize='"
|
|
|
|
|
in
|
|
|
|
|
let consume_input i =
|
|
|
|
|
try
|
|
|
|
|
while true do
|
|
|
|
|
let line = In_channel.input_line_exn i in
|
|
|
|
|
(* keep only commands and errors *)
|
|
|
|
|
if Str.string_match commands_or_errors line 0 then normalized_commands
|
|
|
|
|
:= one_line line :: !normalized_commands
|
|
|
|
|
if Str.string_match commands_or_errors line 0
|
|
|
|
|
&& not (Str.string_match ignored_errors line 0)
|
|
|
|
|
then normalized_commands := one_line line :: !normalized_commands
|
|
|
|
|
done
|
|
|
|
|
with End_of_file -> ()
|
|
|
|
|
in
|
|
|
|
@ -110,13 +114,13 @@ let normalize ~prog ~args : action_item list =
|
|
|
|
|
!normalized_commands
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let exec_action_item = function
|
|
|
|
|
let exec_action_item ~prog ~args = function
|
|
|
|
|
| ClangError error ->
|
|
|
|
|
(* An error in the output of `clang -### ...`. Outputs the error and fail. This is because
|
|
|
|
|
`clang -###` pretty much never fails, but warns of failures on stderr instead. *)
|
|
|
|
|
L.(die UserError)
|
|
|
|
|
"Failed to execute compilation command. Output:@\n%s@\n*** Infer needs a working compilation command to run."
|
|
|
|
|
error
|
|
|
|
|
"Failed to execute compilation command:@\n'%s' %a@\n@\nError message:@\n%s@\n@\n*** Infer needs a working compilation command to run."
|
|
|
|
|
prog Pp.cli_args args error
|
|
|
|
|
| ClangWarning warning ->
|
|
|
|
|
L.external_warning "%s@\n" warning
|
|
|
|
|
| Command clang_cmd ->
|
|
|
|
@ -140,7 +144,7 @@ let exe ~prog ~args =
|
|
|
|
|
| None ->
|
|
|
|
|
(clang_xx, false)
|
|
|
|
|
in
|
|
|
|
|
List.iter ~f:exec_action_item commands ;
|
|
|
|
|
List.iter ~f:(exec_action_item ~prog ~args) commands ;
|
|
|
|
|
if List.is_empty commands || should_run_original_command then (
|
|
|
|
|
if List.is_empty commands then
|
|
|
|
|
(* No command to execute after -###, let's execute the original command
|
|
|
|
|