fail when clang -### <args> returns nothing

Summary:
Since clang -### can silently return nothing when passed bogus arguments (eg,
trying to compile a non-existent file), run the original command in that case
in case it's a genuine error. This prevents puzzling behaviours such as
`infer -- clang -c bogus_file.c` succeeding with 0 files analyzed.

Reviewed By: martinoluca

Differential Revision: D3592924

fbshipit-source-id: 5d8bc81
master
Jules Villard 8 years ago committed by Facebook Github Bot 5
parent dfb7c15303
commit 354e4c0391

@ -54,7 +54,17 @@ else
sed -e 's#^\(^clang: error:.*$\)#echo "\1"; exit 1#g' | \
# add trailing ; to each line
sed -e 's/$/;/g')
eval $CC_COMMAND
if [ -n "$CC_COMMAND" ]; then
eval $CC_COMMAND
else
# No command to execute after -###, this is fishy, let's execute the original command
# instead.
#
# In particular, this can happen when the user tries to run `infer -- clang -c
# file_that_does_not_exist.c`. In this case, this will fail with the appropriate error
# message from clang instead of silently analyzing 0 files.
"$CLANG_COMPILER$XX" "$@"
fi
STATUS=$?
fi

Loading…
Cancel
Save