xref: /llvm-project/llvm/test/TableGen/code.td (revision 415fab6f67b4db59abe533130272d55b4efbf0cb)
1// RUN: llvm-tblgen %s | FileCheck %s
2// RUN: not llvm-tblgen -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s
3// XFAIL: vg_leak
4
5// CHECK: def A1
6// CHECK:   code CodeCode = [{code here;}]
7// CHECK:   code StringCode = [{code here;}]
8
9// CHECK: def A2
10// CHECK:   string CodeCode = "string here"
11// CHECK:   string StringCode = "string here"
12
13// CHECK: def B1
14// CHECK:   string CodeCode = "with paste 7"
15// CHECK:   string StringCode = "with paste 7"
16
17// CHECK: def C1
18// CHECK:   code CodeCode = [{with concat 42}]
19// CHECK:   code StringCode = [{with concat 42}]
20
21// CHECK: def D1
22// CHECK:   code CodeCode = [{with concat 108!}]
23// CHECK:   code StringCode = [{with concat 108!}]
24
25class A<code c> {
26  code CodeCode = c;
27  string StringCode = c;
28}
29
30def A1 : A<[{code here;}]>;
31def A2 : A<"string here">;
32
33class B<int i> : A<"with paste " # i>;
34class C<int i> : A<!strconcat([{with concat }], !cast<string>(i))>;
35class D<int i> : A<!strconcat([{with concat }], !cast<string>(i), "!")>;
36
37def B1 : B<7>;
38def C1 : C<42>;
39def D1 : D<108>;
40
41#ifdef ERROR1
42
43// ERROR1: the 'code' type is not allowed
44
45def Zerror1 {
46  code Code = !cast<code>("i = 0;");
47}
48
49#endif
50