From 698ebe80496444bca76fc3ada9fd2780bb5eca8f Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Fri, 28 Oct 2016 05:47:21 -0700 Subject: [PATCH] [clang] Remove INFER_XX environment variable Summary: InferClang knows what to do if its name ends in ++. So it is not necessary to pass whether or not the original clang executable ended in ++ to InferClang using the the INFER_XX environment variable. Instead, create an InferClang++ symbolic link and make the clang wrapper call either InferClang or InferClang++ as needed. Reviewed By: jvillard Differential Revision: D4078416 fbshipit-source-id: 3b5d5d0 --- .gitignore | 1 + Makefile | 2 ++ infer/lib/xcode_wrappers/clang | 5 ++--- infer/src/Makefile | 1 + infer/src/clang/InferClang.re | 9 +-------- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 9d468380c..9d6da0491 100644 --- a/.gitignore +++ b/.gitignore @@ -67,6 +67,7 @@ buck-out/ #other /infer/bin/InferAnalyze /infer/bin/InferClang +/infer/bin/InferClang++ /infer/bin/InferJava /infer/bin/InferPrint /infer/bin/InferStatsAggregator diff --git a/Makefile b/Makefile index 71c6b82f7..4980dddbe 100644 --- a/Makefile +++ b/Makefile @@ -268,6 +268,8 @@ ifeq ($(BUILD_C_ANALYZERS),yes) $(INSTALL_DATA) -C $$i $(DESTDIR)$(libdir)/infer/$$i; \ done $(INSTALL_PROGRAM) -C $(INFERCLANG_BIN) $(DESTDIR)$(libdir)/infer/infer/bin/ + (cd $(DESTDIR)$(libdir)/infer/infer/bin/ && \ + $(LN_S) -f $(INFERCLANG_BIN) $(INFERCLANG_BIN)++) $(INSTALL_PROGRAM) -C $(INFER_BUCK_COMPILATION_DATABASE_BIN) $(DESTDIR)$(libdir)/infer/infer/bin/ endif ifneq ($(XCODE_SELECT),no) diff --git a/infer/lib/xcode_wrappers/clang b/infer/lib/xcode_wrappers/clang index ab7360148..af2ece004 100755 --- a/infer/lib/xcode_wrappers/clang +++ b/infer/lib/xcode_wrappers/clang @@ -3,7 +3,6 @@ SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" BIN_PATH="${SCRIPT_PATH}/../../bin" -if [ "${0%++}" != "$0" ]; then INFER_XX="++"; fi -export INFER_XX +if [ "${0%++}" != "$0" ]; then XX="++"; else XX=""; fi -"${BIN_PATH}/InferClang" "$@" +"${BIN_PATH}/InferClang${XX}" "$@" diff --git a/infer/src/Makefile b/infer/src/Makefile index 3fa29fd66..e3a1df01d 100644 --- a/infer/src/Makefile +++ b/infer/src/Makefile @@ -198,6 +198,7 @@ ifeq ($(BUILD_JAVA_ANALYZERS),yes) endif ifeq ($(BUILD_C_ANALYZERS),yes) $(COPY) $(INFER_BUILD_DIR)/$(INFERCLANG_MAIN).native $(INFERCLANG_BIN) + cd $(INFER_BUILD_DIR) && $(LN_S) -f InferClang InferClang++ && cd - $(COPY) $(INFER_BUILD_DIR)/$(BUCK_COMPILATION_DATABASE_MAIN).native $(INFER_BUCK_COMPILATION_DATABASE_BIN) endif ifeq ($(ENABLE_OCAML_ANNOT),yes) diff --git a/infer/src/clang/InferClang.re b/infer/src/clang/InferClang.re index 2fd42eea2..597e44084 100644 --- a/infer/src/clang/InferClang.re +++ b/infer/src/clang/InferClang.re @@ -9,14 +9,7 @@ open! Utils; let () = { - let xx_suffix = - if (string_is_suffix "++" Sys.argv.(0)) { - "++" - } else { - try (Sys.getenv "INFER_XX") { - | Not_found => "" - } - }; + let xx_suffix = string_is_suffix "++" Sys.argv.(0) ? "++" : ""; let args = Array.copy Sys.argv; /* make sure we don't call ourselves recursively */ args.(0) = CFrontend_config.clang_bin xx_suffix;