1 // Test for the OptionPreprocessor and related functionality.
2 // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t
3 // RUN: FileCheck -input-file %t %s
4 // RUN: %compile_cxx %t
7 include "llvm/CompilerDriver/Common.td"
9 def OptList : OptionList<[
10 (switch_option "foo", (help "dummy")),
11 (switch_option "bar", (help "dummy")),
12 (switch_option "baz", (help "dummy")),
13 (parameter_option "foo_p", (help "dummy")),
14 (parameter_option "bar_p", (help "dummy")),
15 (parameter_option "baz_p", (help "dummy")),
16 (parameter_list_option "foo_l", (help "dummy"))
19 def Preprocess : OptionPreprocessor<
22 // CHECK: foo = false;
24 // CHECK: foo_l.clear();
25 (and (switch_on "foo"), (any_switch_on "bar", "baz")),
26 [(warning "W1"), (unset_option "foo"),
27 (unset_option "foo_p"), (unset_option "foo_l")],
31 // CHECK: baz = false;
32 // CHECK: foo_p = "asdf";
33 // CHECK: foo_l.clear();
34 // CHECK: foo_l.push_back("qwert");
35 // CHECK: foo_l.push_back("yuiop");
36 // CHECK: foo_l.push_back("asdf");
37 (and (switch_on "foo", "bar"), (any_empty "foo_p", "bar_p")),
38 [(warning "W2"), (set_option "foo"),
39 (set_option "bar", true),
40 (set_option "baz", false),
41 (set_option "foo_p", "asdf"),
42 (set_option "foo_l", ["qwert", "yuiop", "asdf"])],
47 (and (empty "foo_p", "bar_p"), (any_not_empty "baz_p")),
48 [(warning "W3"), (set_option "foo", "bar", "baz")])
51 // Shut up warnings...
53 [(in_language "dummy"),
54 (out_language "dummy"),
57 (actions (case (switch_on "foo"), (error),
58 (switch_on "bar"), (error),
59 (switch_on "baz"), (error),
60 (not_empty "foo_p"), (error),
61 (not_empty "bar_p"), (error),
62 (not_empty "baz_p"), (error),
63 (not_empty "foo_l"), (error)))
66 def Graph : CompilationGraph<[(edge "root", "dummy")]>;