From 0817ab0ec221d97c6685e0f22f88c967b2b471df Mon Sep 17 00:00:00 2001 From: Andrzej Kotulski Date: Thu, 8 Sep 2016 16:17:24 -0700 Subject: [PATCH] Fix FCP_RUN_SYNTAX_ONLY variable Summary: When we switched scripts to run `-cc1` commands coming from `-###` invocation we broke passing `-fsyntax-only` argument. Reviewed By: jberdine Differential Revision: D3835751 fbshipit-source-id: a742db4 --- .../attach_plugin_and_run_clang_frontend.sh | 9 +++++---- .../clang_wrappers/hijack_and_normalize_clang_command.sh | 9 ++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/infer/lib/clang_wrappers/attach_plugin_and_run_clang_frontend.sh b/infer/lib/clang_wrappers/attach_plugin_and_run_clang_frontend.sh index 1fcbc91db..fae4c50b9 100755 --- a/infer/lib/clang_wrappers/attach_plugin_and_run_clang_frontend.sh +++ b/infer/lib/clang_wrappers/attach_plugin_and_run_clang_frontend.sh @@ -104,10 +104,6 @@ CLANG_CMD+=( "-plugin-arg-${PLUGIN_NAME}" "PREPEND_CURRENT_DIR=1") -if [ -n "$SYNTAX_ONLY" ]; then - CLANG_CMD+=("-fsyntax-only") -fi - if [ -n "$LLVM_MODE" ]; then CLANG_CMD+=("-o" "-" "-g" "-S" "-emit-llvm") fi @@ -122,6 +118,11 @@ if ! [[ "$SOURCE_FILENAME" = /* ]]; then SOURCE_FILENAME="$(pwd)/$SOURCE_FILENAME" fi +# add fsyntax-only to the end of arg list to override previous options +if [ -n "$SYNTAX_ONLY" ]; then + CLANG_CMD+=("-fsyntax-only") +fi + if [ -n "$LLVM_MODE" ]; then INFER_FRONTEND_CMD=( "${BIN_DIR}/InferLLVM" diff --git a/infer/lib/clang_wrappers/hijack_and_normalize_clang_command.sh b/infer/lib/clang_wrappers/hijack_and_normalize_clang_command.sh index c94ebc51e..b5b7dd76f 100755 --- a/infer/lib/clang_wrappers/hijack_and_normalize_clang_command.sh +++ b/infer/lib/clang_wrappers/hijack_and_normalize_clang_command.sh @@ -26,8 +26,11 @@ APPLE_CLANG="$FCP_APPLE_CLANG" # Main if [ "${0%++}" != "$0" ]; then XX="++"; fi +# Skip -cc1as commands +if [ "$1" = "-cc1as" ]; then + STATUS=0 # Normalize clang command if not -cc1 already. -cc1 is always the first argument if present. -if [ "$1" = "-cc1" ]; then +elif [ "$1" = "-cc1" ]; then "$CLANG_CC1_CAPTURE" "$@" STATUS=$? else @@ -50,6 +53,10 @@ else grep -e '^\([[:space:]]\"\|clang: error:\)' | \ # replace -cc1 commands with our clang wrapper sed -e "s#^[[:space:]]\"\([^\"]*\)\" \"-cc1\" \(.*\)\$# \"$CLANG_CC1_CAPTURE\" \"-cc1\" \2#g" | \ + # do not run if language is assembler or assembler-with-cpp + grep -v -- '"-x" "assembler' | \ + # do not run -cc1as commands + grep -v -- '"-cc1as"' | \ # replace error messages by failures sed -e 's#^\(^clang: error:.*$\)#echo "\1"; exit 1#g' | \ # add trailing ; to each line