Include C++ models only in --cxx mode

Summary:public
Models in headers are purely C++ concept and it's
useless if C++ mode is turned off. Since those
models can lead to compilation errors, turn them
off for non-C++ analysis

Reviewed By: martinoluca

Differential Revision: D3126294

fb-gh-sync-id: 0912e7b
fbshipit-source-id: 0912e7b
master
Andrzej Kotulski 9 years ago committed by Facebook Github Bot 0
parent a227202adc
commit a8de56e9bf

@ -38,6 +38,8 @@ REPORT_FRONTEND_FAILURE="${FCP_REPORT_FRONTEND_FAILURE}"
DEBUG_MODE="${FCP_DEBUG_MODE}" DEBUG_MODE="${FCP_DEBUG_MODE}"
# specify where is located Apple's clang # specify where is located Apple's clang
APPLE_CLANG="${FCP_APPLE_CLANG}" APPLE_CLANG="${FCP_APPLE_CLANG}"
# whether to amend include search path with C++ model headers
INFER_CXX_MODELS="${FCP_INFER_CXX_MODELS}"
if [ -z "$RESULTS_DIR" ]; then if [ -z "$RESULTS_DIR" ]; then
echo '$FCP_RESULTS_DIR with the name of the output directory not provided.' > /dev/stderr echo '$FCP_RESULTS_DIR with the name of the output directory not provided.' > /dev/stderr
@ -45,7 +47,14 @@ if [ -z "$RESULTS_DIR" ]; then
fi fi
if [ "${0%++}" != "$0" ]; then XX="++"; else XX=""; fi if [ "${0%++}" != "$0" ]; then XX="++"; else XX=""; fi
CLANG_CMD=("${CLANG_COMPILER}${XX}" "$@")
EXTRA_INCLUDE_PATH=()
if [ -n "$INFER_CXX_MODELS" ]; then
EXTRA_INCLUDE_PATH+=("-isystem")
EXTRA_INCLUDE_PATH+=("${SCRIPT_DIR}/../../models/cpp/include")
fi
CLANG_CMD=("${CLANG_COMPILER}${XX}" "${EXTRA_INCLUDE_PATH[@]}" "$@")
CWD=$(pwd) CWD=$(pwd)
CWD="${CWD%/}" CWD="${CWD%/}"
[ ! -d "$RESULTS_DIR" ] && mkdir -p "$RESULTS_DIR" [ ! -d "$RESULTS_DIR" ] && mkdir -p "$RESULTS_DIR"

@ -11,8 +11,6 @@ CLANG_COMPILER="${SCRIPT_DIR}/../../../facebook-clang-plugins/clang/bin/clang"
if [ "${0%++}" != "$0" ]; then XX="++"; else XX=""; fi if [ "${0%++}" != "$0" ]; then XX="++"; else XX=""; fi
COMMAND=("${CLANG_COMPILER}${XX}") COMMAND=("${CLANG_COMPILER}${XX}")
COMMAND+=("-isystem")
COMMAND+=("${SCRIPT_DIR}/../../models/cpp/include")
# Remove command line options not supported by the opensource compiler or the plugins. # Remove command line options not supported by the opensource compiler or the plugins.
PREV="" PREV=""

@ -105,7 +105,7 @@ def clang_frontend_argparser(description, module_name):
'--cxx', '--cxx',
dest='cxx', dest='cxx',
action='store_true', action='store_true',
help='Analyze C++ methods, still experimental') help='Analyze C++ code, still experimental')
group.add_argument( group.add_argument(
'-fs', '--frontend-stats', '-fs', '--frontend-stats',
dest='frontend_stats', dest='frontend_stats',
@ -138,6 +138,7 @@ def get_clang_frontend_envvars(args):
frontend_args.append('-testing_mode') frontend_args.append('-testing_mode')
if args.cxx: if args.cxx:
frontend_args.append('-cxx-experimental') frontend_args.append('-cxx-experimental')
env_vars['FCP_INFER_CXX_MODELS'] = '1'
if args.frontend_debug: if args.frontend_debug:
frontend_args += ['-debug'] frontend_args += ['-debug']
env_vars['FCP_DEBUG_MODE'] = '1' env_vars['FCP_DEBUG_MODE'] = '1'

Loading…
Cancel
Save