OSDN Git Service

TableGen: Fix type deduction for !foreach
[android-x86/external-llvm.git] / test / TableGen / foreach.td
1 // RUN: llvm-tblgen %s | FileCheck %s
2 // XFAIL: vg_leak
3
4 // CHECK: Classes
5 // CHECK: Sr
6 // CHECK: Jr
7 // CHECK: "NAME"
8
9 // CHECK: Defs
10
11 // CHECK: def DX {
12 // CHECK:   list<string> x = ["0", "1", "2"];
13 // CHECK: }
14
15 // CHECK: Jr
16 // CHECK: Sr
17
18 // Variables for foreach
19 class decls {
20   string name;
21   int num;
22 }
23
24 def Decls : decls;
25
26 class A<list<string> names> {
27   list<string> Names = names;
28 }
29
30 class B<list<string> names> : A<!foreach(Decls.name, names, !strconcat(Decls.name, ", Sr."))>;
31
32 class C<list<string> names> : A<!foreach(Decls.name, names, !strconcat(Decls.name, ", Jr."))>;
33
34 class D<list<string> names> : A<!foreach(Decls.name, names, !subst("NAME", "John Smith", Decls.name))>;
35
36 class Names {
37   list<string> values = ["Ken Griffey", "Seymour Cray"];
38 }
39
40 def People : Names;
41
42 def Seniors : B<People.values>;
43 def Juniors : C<People.values>;
44 def Smiths : D<["NAME", "Jane Smith"]>;
45 def Unprocessed : D<People.values>;
46
47 class X<list<int> a> {
48     list<string> x = !foreach(Decls.num, a, !cast<string>(Decls.num));
49 }
50
51 def DX : X<[0, 1, 2]>;