5661db865d7cc8eca21de8fa687cf33791da57bd
[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 ]>;
16
17 def Preprocess : OptionPreprocessor<
18 (case
19       // CHECK: W1
20       (and (switch_on "foo"), (any_switch_on ["bar", "baz"])),
21            (warning "W1"),
22       // CHECK: W2
23       (and (switch_on ["foo", "bar"]), (any_empty ["foo_p", "bar_p"])),
24            (warning "W2"),
25       // CHECK: W3
26       (and (empty ["foo_p", "bar_p"]), (any_not_empty ["baz_p"])),
27            (warning "W3"))
28 >;
29
30 // Shut up warnings...
31 def dummy : Tool<
32 [(in_language "dummy"),
33  (out_language "dummy"),
34  (output_suffix "d"),
35  (cmd_line "dummy $INFILE -o $OUTFILE"),
36  (actions (case (switch_on "foo"), (error),
37                 (switch_on "bar"), (error),
38                 (switch_on "baz"), (error),
39                 (not_empty "foo_p"), (error),
40                 (not_empty "bar_p"), (error),
41                 (not_empty "baz_p"), (error)))
42 ]>;
43
44 def Graph : CompilationGraph<[Edge<"root", "dummy">]>;
45