[llvm] b094258 - Updated the OCaml/bitwriter.ml test for OCaml 4.06+

Dmitri Gribenko via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 30 04:35:38 PST 2019


Author: Dmitri Gribenko
Date: 2019-11-30T13:35:23+01:00
New Revision: b094258661e0064133679b8b51e981eefda07ec7

URL: https://github.com/llvm/llvm-project/commit/b094258661e0064133679b8b51e981eefda07ec7
DIFF: https://github.com/llvm/llvm-project/commit/b094258661e0064133679b8b51e981eefda07ec7.diff

LOG: Updated the OCaml/bitwriter.ml test for OCaml 4.06+

Since OCaml 4.02 (released in 2014), strings and bytes are different
types, but up until OCaml 4.06, the compiler defaulted to a
compatibility mode "unsafe-string". OCaml 4.06 flips the default to
"safe-string", breaking the test.

This change should be compatible with OCaml 4.02+, but is only truly
necessary for OCaml 4.06+.

For more information, see:

https://caml.inria.fr/pub/docs/manual-ocaml/libref/String.html
https://ocaml.org/releases/4.02.html

Added: 
    

Modified: 
    llvm/test/Bindings/OCaml/bitwriter.ml

Removed: 
    


################################################################################
diff  --git a/llvm/test/Bindings/OCaml/bitwriter.ml b/llvm/test/Bindings/OCaml/bitwriter.ml
index 28a61fee91b1..17111bd3b51e 100644
--- a/llvm/test/Bindings/OCaml/bitwriter.ml
+++ b/llvm/test/Bindings/OCaml/bitwriter.ml
@@ -17,7 +17,7 @@ let test x = if not x then exit 1 else ()
 let read_file name =
   let ic = open_in_bin name in
   let len = in_channel_length ic in
-  let buf = String.create len in
+  let buf = Bytes.create len in
 
   test ((input ic buf 0 len) = len);
 
@@ -46,4 +46,4 @@ let _ =
   test (file_buf = temp_bitcode m);
   test (file_buf = temp_bitcode ~unbuffered:false m);
   test (file_buf = temp_bitcode ~unbuffered:true m);
-  test (file_buf = Llvm.MemoryBuffer.as_string (Llvm_bitwriter.write_bitcode_to_memory_buffer m))
+  test (file_buf = Bytes.of_string (Llvm.MemoryBuffer.as_string (Llvm_bitwriter.write_bitcode_to_memory_buffer m)))


        


More information about the llvm-commits mailing list