From a8de56e9bfa5fe74943630ec1555d4b88e84f4ff Mon Sep 17 00:00:00 2001 From: Andrzej Kotulski Date: Fri, 1 Apr 2016 07:31:16 -0700 Subject: [PATCH] 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 --- infer/lib/clang_wrappers/clang_general_wrapper | 11 ++++++++++- infer/lib/clang_wrappers/clang_wrapper | 2 -- infer/lib/python/inferlib/capture/util.py | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/infer/lib/clang_wrappers/clang_general_wrapper b/infer/lib/clang_wrappers/clang_general_wrapper index e497a5878..72a4bce7b 100755 --- a/infer/lib/clang_wrappers/clang_general_wrapper +++ b/infer/lib/clang_wrappers/clang_general_wrapper @@ -38,6 +38,8 @@ REPORT_FRONTEND_FAILURE="${FCP_REPORT_FRONTEND_FAILURE}" DEBUG_MODE="${FCP_DEBUG_MODE}" # specify where is located Apple's 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 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 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="${CWD%/}" [ ! -d "$RESULTS_DIR" ] && mkdir -p "$RESULTS_DIR" diff --git a/infer/lib/clang_wrappers/clang_wrapper b/infer/lib/clang_wrappers/clang_wrapper index 604619555..eca5f3517 100755 --- a/infer/lib/clang_wrappers/clang_wrapper +++ b/infer/lib/clang_wrappers/clang_wrapper @@ -11,8 +11,6 @@ CLANG_COMPILER="${SCRIPT_DIR}/../../../facebook-clang-plugins/clang/bin/clang" if [ "${0%++}" != "$0" ]; then XX="++"; else XX=""; fi 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. PREV="" diff --git a/infer/lib/python/inferlib/capture/util.py b/infer/lib/python/inferlib/capture/util.py index 5be188d11..e051388fc 100644 --- a/infer/lib/python/inferlib/capture/util.py +++ b/infer/lib/python/inferlib/capture/util.py @@ -105,7 +105,7 @@ def clang_frontend_argparser(description, module_name): '--cxx', dest='cxx', action='store_true', - help='Analyze C++ methods, still experimental') + help='Analyze C++ code, still experimental') group.add_argument( '-fs', '--frontend-stats', dest='frontend_stats', @@ -138,6 +138,7 @@ def get_clang_frontend_envvars(args): frontend_args.append('-testing_mode') if args.cxx: frontend_args.append('-cxx-experimental') + env_vars['FCP_INFER_CXX_MODELS'] = '1' if args.frontend_debug: frontend_args += ['-debug'] env_vars['FCP_DEBUG_MODE'] = '1'