xref: /llvm-project/llvm/test/TableGen/foreach-leak.td (revision 013116cd7077bdab2167196486c334080396f6fd)
1// RUN: llvm-tblgen %s | FileCheck %s
2// XFAIL: vg_leak
3
4// CHECK: --- Classes ---
5// CHECK: list<int> ret = !foreach(a,
6
7// CHECK: --- Defs ---
8
9// CHECK: def C0 {
10// CHECK{LITERAL}: list<list<int>> ret = [[1, 2, 3], [1, 2, 3]];
11// CHECK: }
12
13// The variable name 'a' is used both in the "inner" and in the "outer" foreach.
14// The test ensure that the inner declaration of 'a' properly shadows the outer
15// one.
16class A<list<int> lst> {
17  list<int> ret = !foreach(a, lst, !add(a, 1));
18}
19
20class B<list<int> lst1, list<int> lst2> {
21  list<list<int>> ret = !foreach(a, lst1, A<lst2>.ret);
22}
23
24class C<list<int> lst2> {
25  list<list<int>> ret = B<[0, 1], lst2>.ret;
26}
27
28def C0 : C<[0, 1, 2]>;
29