// RUN: llvm-tblgen %s | FileCheck %s // XFAIL: vg_leak // CHECK: --- Defs --- // CHECK: def A1 { // CHECK: int ret = 0; // CHECK: } // CHECK: def A2 { // CHECK: int ret = 5; // CHECK: } // CHECK: def A3 { // CHECK: int ret = 10; // CHECK: } // CHECK: def B1 { // CHECK: list ret = []; // CHECK: } // CHECK: def B2 { // CHECK: list ret = []; // CHECK: } // CHECK: def B3 { // CHECK: list ret = ["a"]; // CHECK: } // CHECK: def B4 { // CHECK: list ret = ["a", "b", "c", "d"]; // CHECK: } // CHECK: def E0 { // CHECK: list ret = [45, 45, 45, 45]; // CHECK: } class Sum lst> { int ret = !foldl(0, lst, a, b, !add(a, b)); } class Flatten> lst> { list ret = !foldl([], lst, a, b, !listconcat(a, b)); } def A1 : Sum<[]>; def A2 : Sum<[5]>; def A3 : Sum<[1, 2, 3, 4]>; def B1 : Flatten<[]>; def B2 : Flatten<[[]]>; def B3 : Flatten<[["a"]]>; def B4 : Flatten<[["a", "b"], [], ["c"], ["d"]]>; // The variables a and b are declared both in the "inner" foldl and in the // other foreach. The test checks that they don't "leak". class C lst> { int ret = !foldl(0, lst, a, b, !add(a, b)); } class D lst1, list lst2> { list x = !foreach(a, lst1, C.ret); list y = !foreach(b, lst1, C.ret); list z = !listconcat(x, y); } class E lst2> { list ret = D<[0, 1], lst2>.z; } def E0 : E<[10, 15, 20]>;