1 // RUN: llvm-tblgen %s | FileCheck %s
11 // CHECK: int ret = 5;
15 // CHECK: int ret = 10;
19 // CHECK: list<string> ret = [];
23 // CHECK: list<string> ret = [];
27 // CHECK: list<string> ret = ["a"];
31 // CHECK: list<string> ret = ["a", "b", "c", "d"];
35 // CHECK: list<int> ret = [45, 45, 45, 45];
38 class Sum<list<int> lst> {
39 int ret = !foldl(0, lst, a, b, !add(a, b));
42 class Flatten<list<list<string>> lst> {
43 list<string> ret = !foldl([]<string>, lst, a, b, !listconcat(a, b));
48 def A3 : Sum<[1, 2, 3, 4]>;
51 def B2 : Flatten<[[]]>;
52 def B3 : Flatten<[["a"]]>;
53 def B4 : Flatten<[["a", "b"], [], ["c"], ["d"]]>;
55 // The variables a and b are declared both in the "inner" foldl and in the
56 // other foreach. The test checks that they don't "leak".
57 class C<list<int> lst> {
58 int ret = !foldl(0, lst, a, b, !add(a, b));
61 class D<list<int> lst1, list<int> lst2> {
62 list<int> x = !foreach(a, lst1, C<lst2>.ret);
63 list<int> y = !foreach(b, lst1, C<lst2>.ret);
64 list<int> z = !listconcat(x, y);
67 class E<list<int> lst2> {
68 list<int> ret = D<[0, 1], lst2>.z;
71 def E0 : E<[10, 15, 20]>;