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