]>
Commit | Line | Data |
---|---|---|
85aaf69f SL |
1 | (* RUN: cp %s %T/analysis.ml |
2 | * RUN: %ocamlc -g -warn-error A -package llvm.analysis -linkpkg %T/analysis.ml -o %t | |
3 | * RUN: %t | |
4 | * RUN: %ocamlopt -g -warn-error A -package llvm.analysis -linkpkg %T/analysis.ml -o %t | |
223e47cc LB |
5 | * RUN: %t |
6 | * XFAIL: vg_leak | |
7 | *) | |
8 | ||
9 | open Llvm | |
10 | open Llvm_analysis | |
11 | ||
12 | (* Note that this takes a moment to link, so it's best to keep the number of | |
13 | individual tests low. *) | |
14 | ||
15 | let context = global_context () | |
16 | ||
17 | let test x = if not x then exit 1 else () | |
18 | ||
19 | let bomb msg = | |
20 | prerr_endline msg; | |
21 | exit 2 | |
22 | ||
23 | let _ = | |
24 | let fty = function_type (void_type context) [| |] in | |
25 | let m = create_module context "valid_m" in | |
26 | let fn = define_function "valid_fn" fty m in | |
27 | let at_entry = builder_at_end context (entry_block fn) in | |
28 | ignore (build_ret_void at_entry); | |
85aaf69f SL |
29 | |
30 | ||
223e47cc LB |
31 | (* Test that valid constructs verify. *) |
32 | begin match verify_module m with | |
33 | Some msg -> bomb "valid module failed verification!" | |
34 | | None -> () | |
35 | end; | |
85aaf69f | 36 | |
223e47cc | 37 | if not (verify_function fn) then bomb "valid function failed verification!"; |
85aaf69f SL |
38 | |
39 | ||
223e47cc LB |
40 | (* Test that invalid constructs do not verify. |
41 | A basic block can contain only one terminator instruction. *) | |
42 | ignore (build_ret_void at_entry); | |
85aaf69f | 43 | |
223e47cc LB |
44 | begin match verify_module m with |
45 | Some msg -> () | |
46 | | None -> bomb "invalid module passed verification!" | |
47 | end; | |
85aaf69f | 48 | |
223e47cc | 49 | if verify_function fn then bomb "invalid function passed verification!"; |
85aaf69f SL |
50 | |
51 | ||
223e47cc | 52 | dispose_module m |
85aaf69f | 53 | |
223e47cc | 54 | (* Don't bother to test assert_valid_{module,function}. *) |