72 lines · plain
1// RUN: llvm-tblgen %s | FileCheck %s2// XFAIL: vg_leak3 4// CHECK: --- Defs ---5 6// CHECK: def A1 {7// CHECK: int ret = 0;8// CHECK: }9 10// CHECK: def A2 {11// CHECK: int ret = 5;12// CHECK: }13 14// CHECK: def A3 {15// CHECK: int ret = 10;16// CHECK: }17 18// CHECK: def B1 {19// CHECK: list<string> ret = [];20// CHECK: }21 22// CHECK: def B2 {23// CHECK: list<string> ret = [];24// CHECK: }25 26// CHECK: def B3 {27// CHECK: list<string> ret = ["a"];28// CHECK: }29 30// CHECK: def B4 {31// CHECK: list<string> ret = ["a", "b", "c", "d"];32// CHECK: }33 34// CHECK: def E0 {35// CHECK: list<int> ret = [45, 45, 45, 45];36// CHECK: }37 38class Sum<list<int> lst> {39 int ret = !foldl(0, lst, a, b, !add(a, b));40}41 42class Flatten<list<list<string>> lst> {43 list<string> ret = !foldl([]<string>, lst, a, b, !listconcat(a, b));44}45 46def A1 : Sum<[]>;47def A2 : Sum<[5]>;48def A3 : Sum<[1, 2, 3, 4]>;49 50def B1 : Flatten<[]>;51def B2 : Flatten<[[]]>;52def B3 : Flatten<[["a"]]>;53def B4 : Flatten<[["a", "b"], [], ["c"], ["d"]]>;54 55// The variables a and b are declared both in the "inner" foldl and in the56// other foreach. The test checks that they don't "leak".57class C<list<int> lst> {58 int ret = !foldl(0, lst, a, b, !add(a, b));59}60 61class 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);65}66 67class E<list<int> lst2> {68 list<int> ret = D<[0, 1], lst2>.z;69}70 71def E0 : E<[10, 15, 20]>;72