xref: /aosp_15_r20/external/llvm/test/Bindings/OCaml/ext_exc.ml (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker(* RUN: cp %s %T/ext_exc.ml
2*9880d681SAndroid Build Coastguard Worker * RUN: %ocamlc -g -w +A -package llvm.bitreader -linkpkg %T/ext_exc.ml -o %t
3*9880d681SAndroid Build Coastguard Worker * RUN: %t
4*9880d681SAndroid Build Coastguard Worker * RUN: %ocamlopt -g -w +A -package llvm.bitreader -linkpkg %T/ext_exc.ml -o %t
5*9880d681SAndroid Build Coastguard Worker * RUN: %t
6*9880d681SAndroid Build Coastguard Worker * XFAIL: vg_leak
7*9880d681SAndroid Build Coastguard Worker *)
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Workerlet context = Llvm.global_context ()
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Workerlet diagnostic_handler _ = ()
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Worker(* This used to crash, we must not use 'external' in .mli files, but 'val' if we
14*9880d681SAndroid Build Coastguard Worker * want the let _ bindings executed, see http://caml.inria.fr/mantis/view.php?id=4166 *)
15*9880d681SAndroid Build Coastguard Workerlet _ =
16*9880d681SAndroid Build Coastguard Worker    Llvm.set_diagnostic_handler context (Some diagnostic_handler);
17*9880d681SAndroid Build Coastguard Worker    try
18*9880d681SAndroid Build Coastguard Worker        ignore (Llvm_bitreader.get_module context (Llvm.MemoryBuffer.of_stdin ()))
19*9880d681SAndroid Build Coastguard Worker    with
20*9880d681SAndroid Build Coastguard Worker    Llvm_bitreader.Error _ -> ();;
21*9880d681SAndroid Build Coastguard Workerlet _ =
22*9880d681SAndroid Build Coastguard Worker    try
23*9880d681SAndroid Build Coastguard Worker        ignore (Llvm.MemoryBuffer.of_file "/path/to/nonexistent/file")
24*9880d681SAndroid Build Coastguard Worker    with
25*9880d681SAndroid Build Coastguard Worker    Llvm.IoError _ -> ();;
26