Index: lib/TableGen/TGParser.cpp =================================================================== --- lib/TableGen/TGParser.cpp +++ lib/TableGen/TGParser.cpp @@ -142,6 +142,9 @@ V = BitsInit::get(NewBits); } + if (!CurMultiClass) + V = V->resolveReferences(*CurRec, RV); + if (RV->setValue(V)) { std::string InitType; if (BitsInit *BI = dyn_cast(V)) Index: test/TableGen/bug30254.td =================================================================== --- /dev/null +++ test/TableGen/bug30254.td @@ -0,0 +1,50 @@ +// RUN: llvm-tblgen %s | FileCheck %s +// XFAIL: vg_leak + +class Operand {} + +def Enum : Operand { + int AAA = 1; + int BBB = 2; +} + +// CHECK: class getString +// CHECK-NEXT: string ret = !if(!eq(getString:Selector, 1), "AAA", !if(!eq(getString:Selector, 2), "BBB", "")); +class getString { + string ret = + !if(!eq(Selector, Enum.AAA), "AAA", + !if(!eq(Selector, Enum.BBB), "BBB", + "")); +} + + +class S { + string v1 = getString.ret; // <-- Doesnt resolve! + string v2 = getString.ret; // <-- but this resolve! +} + +// Works ok + +// CHECK: def C1 { +// CHECK: int S:SelectorCopy = 1; +// CHECK: string v1 = "AAA"; +// CHECK: string v2 = "AAA"; +def C1 : S <1>; + +// CHECK: def C2 { +// CHECK: int S:SelectorCopy = 2; +// CHECK: string v1 = "BBB"; +// CHECK: string v2 = "BBB"; +def C2 : S <2>; + +// Incorrect version, S:v1 doesnt resolve to a string + +// CHECK: def W1 { +// CHECK: string v1 = "AAA"; +// CHECK: string v2 = "AAA"; +def W1 : S ; + +// CHECK: def W2 { +// CHECK: string v1 = "BBB"; +// CHECK: string v2 = "BBB"; +def W2 : S ;