2009-12-23 12:49:30 +00:00
|
|
|
// Test for the OptionPreprocessor and related functionality.
|
2009-12-15 07:21:14 +00:00
|
|
|
// RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t
|
|
|
|
// RUN: FileCheck -input-file %t %s
|
2010-01-27 10:08:08 +00:00
|
|
|
// RUN: %compile_cxx -fexceptions -x c++ %t
|
2010-03-21 08:12:46 +00:00
|
|
|
// XFAIL: vg_leak
|
2009-10-25 01:43:50 +00:00
|
|
|
|
|
|
|
include "llvm/CompilerDriver/Common.td"
|
|
|
|
|
|
|
|
def OptList : OptionList<[
|
|
|
|
(switch_option "foo", (help "dummy")),
|
|
|
|
(switch_option "bar", (help "dummy")),
|
|
|
|
(switch_option "baz", (help "dummy")),
|
|
|
|
(parameter_option "foo_p", (help "dummy")),
|
|
|
|
(parameter_option "bar_p", (help "dummy")),
|
2009-12-17 07:49:16 +00:00
|
|
|
(parameter_option "baz_p", (help "dummy")),
|
|
|
|
(parameter_list_option "foo_l", (help "dummy"))
|
2009-10-25 01:43:50 +00:00
|
|
|
]>;
|
|
|
|
|
|
|
|
def Preprocess : OptionPreprocessor<
|
2009-12-15 07:21:14 +00:00
|
|
|
(case
|
|
|
|
// CHECK: W1
|
2009-12-17 07:49:16 +00:00
|
|
|
// CHECK: foo = false;
|
|
|
|
// CHECK: foo_p = "";
|
|
|
|
// CHECK: foo_l.clear();
|
2009-12-15 07:21:14 +00:00
|
|
|
(and (switch_on "foo"), (any_switch_on ["bar", "baz"])),
|
2009-12-17 07:49:16 +00:00
|
|
|
[(warning "W1"), (unset_option "foo"),
|
|
|
|
(unset_option "foo_p"), (unset_option "foo_l")],
|
2009-12-15 07:21:14 +00:00
|
|
|
// CHECK: W2
|
2009-12-17 07:49:16 +00:00
|
|
|
// CHECK: foo = true;
|
2009-12-23 12:49:30 +00:00
|
|
|
// CHECK: bar = true;
|
|
|
|
// CHECK: baz = false;
|
2009-12-17 07:49:16 +00:00
|
|
|
// CHECK: foo_p = "asdf";
|
2009-12-18 11:27:26 +00:00
|
|
|
// CHECK: foo_l.clear();
|
|
|
|
// CHECK: foo_l.push_back("qwert");
|
|
|
|
// CHECK: foo_l.push_back("yuiop");
|
|
|
|
// CHECK: foo_l.push_back("asdf");
|
2009-10-25 01:43:50 +00:00
|
|
|
(and (switch_on ["foo", "bar"]), (any_empty ["foo_p", "bar_p"])),
|
2009-12-23 12:49:30 +00:00
|
|
|
[(warning "W2"), (set_option "foo"),
|
|
|
|
(set_option "bar", true),
|
|
|
|
(set_option "baz", false),
|
|
|
|
(set_option "foo_p", "asdf"),
|
2009-12-18 11:27:26 +00:00
|
|
|
(set_option "foo_l", ["qwert", "yuiop", "asdf"])],
|
2009-12-15 07:21:14 +00:00
|
|
|
// CHECK: W3
|
2009-12-17 07:49:16 +00:00
|
|
|
// CHECK: foo = true;
|
|
|
|
// CHECK: bar = true;
|
|
|
|
// CHECK: baz = true;
|
2009-10-25 01:43:50 +00:00
|
|
|
(and (empty ["foo_p", "bar_p"]), (any_not_empty ["baz_p"])),
|
2009-12-17 07:49:16 +00:00
|
|
|
[(warning "W3"), (set_option ["foo", "bar", "baz"])])
|
2009-10-25 01:43:50 +00:00
|
|
|
>;
|
|
|
|
|
|
|
|
// Shut up warnings...
|
|
|
|
def dummy : Tool<
|
|
|
|
[(in_language "dummy"),
|
|
|
|
(out_language "dummy"),
|
|
|
|
(output_suffix "d"),
|
2010-02-23 09:04:51 +00:00
|
|
|
(command "dummy"),
|
2009-10-25 01:43:50 +00:00
|
|
|
(actions (case (switch_on "foo"), (error),
|
|
|
|
(switch_on "bar"), (error),
|
|
|
|
(switch_on "baz"), (error),
|
|
|
|
(not_empty "foo_p"), (error),
|
|
|
|
(not_empty "bar_p"), (error),
|
2009-12-17 07:49:16 +00:00
|
|
|
(not_empty "baz_p"), (error),
|
|
|
|
(not_empty "foo_l"), (error)))
|
2009-10-25 01:43:50 +00:00
|
|
|
]>;
|
|
|
|
|
|
|
|
def Graph : CompilationGraph<[Edge<"root", "dummy">]>;
|
|
|
|
|