Make the ptrtoint comparison simplification work if one side is a global.
[oota-llvm.git] / test / LLVMC / OptionPreprocessor.td
1 // Test for the OptionPreprocessor and any*.
2 // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t
3 // RUN: FileCheck -input-file %t %s
4 // RUN: %compile_cxx -fexceptions -x c++ %t
5
6 include "llvm/CompilerDriver/Common.td"
7
8 def OptList : OptionList<[
9 (switch_option "foo", (help "dummy")),
10 (switch_option "bar", (help "dummy")),
11 (switch_option "baz", (help "dummy")),
12 (parameter_option "foo_p", (help "dummy")),
13 (parameter_option "bar_p", (help "dummy")),
14 (parameter_option "baz_p", (help "dummy")),
15 (parameter_list_option "foo_l", (help "dummy"))
16 ]>;
17
18 def Preprocess : OptionPreprocessor<
19 (case
20       // CHECK: W1
21       // CHECK: foo = false;
22       // CHECK: foo_p = "";
23       // CHECK: foo_l.clear();
24       (and (switch_on "foo"), (any_switch_on ["bar", "baz"])),
25            [(warning "W1"), (unset_option "foo"),
26                             (unset_option "foo_p"), (unset_option "foo_l")],
27       // CHECK: W2
28       // CHECK: foo = true;
29       // CHECK: foo_p = "asdf";
30       (and (switch_on ["foo", "bar"]), (any_empty ["foo_p", "bar_p"])),
31            [(warning "W2"), (set_option "foo"), (set_option "foo_p", "asdf")],
32       // CHECK: W3
33       // CHECK: foo = true;
34       // CHECK: bar = true;
35       // CHECK: baz = true;
36       (and (empty ["foo_p", "bar_p"]), (any_not_empty ["baz_p"])),
37            [(warning "W3"), (set_option ["foo", "bar", "baz"])])
38 >;
39
40 // Shut up warnings...
41 def dummy : Tool<
42 [(in_language "dummy"),
43  (out_language "dummy"),
44  (output_suffix "d"),
45  (cmd_line "dummy $INFILE -o $OUTFILE"),
46  (actions (case (switch_on "foo"), (error),
47                 (switch_on "bar"), (error),
48                 (switch_on "baz"), (error),
49                 (not_empty "foo_p"), (error),
50                 (not_empty "bar_p"), (error),
51                 (not_empty "baz_p"), (error),
52                 (not_empty "foo_l"), (error)))
53 ]>;
54
55 def Graph : CompilationGraph<[Edge<"root", "dummy">]>;
56