llvm/test/Bindings/OCaml/ext_exc.ml
Jeroen Ketema 828014932b [OCaml] Expose the LLVM diagnostic handler
Differential Revision: http://reviews.llvm.org/D18891


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265897 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-10 13:55:53 +00:00

26 lines
803 B
OCaml

(* RUN: cp %s %T/ext_exc.ml
* RUN: %ocamlc -g -w +A -package llvm.bitreader -linkpkg %T/ext_exc.ml -o %t
* RUN: %t
* RUN: %ocamlopt -g -w +A -package llvm.bitreader -linkpkg %T/ext_exc.ml -o %t
* RUN: %t
* XFAIL: vg_leak
*)
let context = Llvm.global_context ()
let diagnostic_handler _ = ()
(* This used to crash, we must not use 'external' in .mli files, but 'val' if we
* want the let _ bindings executed, see http://caml.inria.fr/mantis/view.php?id=4166 *)
let _ =
Llvm.set_diagnostic_handler context (Some diagnostic_handler);
try
ignore (Llvm_bitreader.get_module context (Llvm.MemoryBuffer.of_stdin ()))
with
Llvm_bitreader.Error _ -> ();;
let _ =
try
ignore (Llvm.MemoryBuffer.of_file "/path/to/nonexistent/file")
with
Llvm.IoError _ -> ();;