From 8dabf716e092f178c0b2bb0e09a20caf5183e5f1 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Mon, 7 Dec 2015 06:55:34 -0800 Subject: [PATCH] remove compilation warnings for OCaml version >= 4.02.0 Summary: public Add the backwards-compatibility Bytes module if we detect OCaml version < 4.02.0. Reviewed By: jberdine Differential Revision: D2728924 fb-gh-sync-id: 39cf76b --- configure.ac | 9 +++++++++ infer/src/Makefile.in | 7 +++++++ infer/src/backend/DB.ml | 2 +- infer/src/backend/dotty.ml | 2 +- infer/src/checkers/models.ml | 2 +- 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 883b25f1f..3eb02a88e 100644 --- a/configure.ac +++ b/configure.ac @@ -54,6 +54,15 @@ AC_ASSERT_OCAML_PKG([easy-format]) AC_ASSERT_OCAML_PKG([ptrees]) AC_ASSERT_OCAML_PKG([yojson]) +OCAMLVERSION_MAJOR=$(printf $OCAMLVERSION | cut -d . -f 1) +OCAMLVERSION_MINOR=$(printf $OCAMLVERSION | cut -d . -f 2) + +OCAML_PKG_bytes=no +# need the bytes package for OCaml version < 4.02.0 +if test "$OCAMLVERSION_MAJOR" -le 4 && test "$OCAMLVERSION_MINOR" -lt 2; then +AC_ASSERT_OCAML_PKG([bytes]) +fi + AC_CHECK_TOOL([ATDGEN], [atdgen], [no]) AC_ASSERT_PROG([atdgen], [$ATDGEN]) AC_SUBST([ATDGEN]) diff --git a/infer/src/Makefile.in b/infer/src/Makefile.in index 55075af85..206729917 100644 --- a/infer/src/Makefile.in +++ b/infer/src/Makefile.in @@ -42,6 +42,13 @@ EASYFORMAT_INCLUDE_DIR = @OCAML_PKG_PATH_easy_format@ OCAML_INCLUDES = -I,$(EASYFORMAT_INCLUDE_DIR),-I,$(BINIOU_INCLUDE_DIR),-I,$(YOJSON_INCLUDE_DIR),-I,$(ATDGEN_INCLUDE_DIR) OCAML_LIBS = unix str atdgen OCAML_MODS = easy_format bi_util bi_share bi_outbuf bi_inbuf bi_vint bi_io yojson ag_oj_run ag_ob_run ag_util + +# backwards compatibility with OCaml version < 4.02.0 +ifneq (@OCAML_PKG_bytes@,no) +BYTES_INCLUDE_DIR = @OCAML_PKG_PATH_bytes@ +OCAML_INCLUDES := $(OCAML_INCLUDES),-I,$(BYTES_INCLUDE_DIR) +endif + OCAMLBUILD_OPTIONS = -lflags -annot \ -cflags -annot,-bin-annot,-warn-error,@5@8@10..12@20@26@39 \ -lflags $(OCAML_INCLUDES) \ diff --git a/infer/src/backend/DB.ml b/infer/src/backend/DB.ml index 3bb5eb59e..7d77cc42b 100644 --- a/infer/src/backend/DB.ml +++ b/infer/src/backend/DB.ml @@ -206,7 +206,7 @@ let create_dir dir = let read_whole_file fd = let stats = Unix.fstat fd in let size = stats.Unix.st_size in - let buf = String.create size in + let buf = Bytes.create size in let nread = Unix.read fd buf 0 size in if nread != size then begin diff --git a/infer/src/backend/dotty.ml b/infer/src/backend/dotty.ml index d6b5d3c63..e4f9ade22 100644 --- a/infer/src/backend/dotty.ml +++ b/infer/src/backend/dotty.ml @@ -112,7 +112,7 @@ let strip_special_chars s = if String.contains st c then begin let idx = String.index st c in try - String.set st idx c'; + Bytes.set st idx c'; st with Invalid_argument _ -> L.out "@\n@\n Invalid argument!!! @\n @.@.@."; assert false end else st in diff --git a/infer/src/checkers/models.ml b/infer/src/checkers/models.ml index 366bb5126..b1000ae87 100644 --- a/infer/src/checkers/models.ml +++ b/infer/src/checkers/models.ml @@ -49,7 +49,7 @@ module Inference = struct let update_boolvec_str _s size index bval = let s = if _s = "" then String.make size '0' else _s in - String.set s index (if bval then '1' else '0'); + Bytes.set s index (if bval then '1' else '0'); s let mark_file update_str dir fname =