Index: lib/TableGen/TGParser.cpp =================================================================== --- lib/TableGen/TGParser.cpp +++ lib/TableGen/TGParser.cpp @@ -1028,7 +1028,13 @@ } Lex.Lex(); // eat the ',' - Init *RHS = ParseValue(CurRec); + // Get the type in case the second operand might be an empty list. We can + // infer the next item's type is the same. + RecTy *MHSTy = 0; + if (TypedInit *MHSt = dyn_cast(MHS)) + MHSTy = MHSt->getType(); + + Init *RHS = ParseValue(CurRec, MHSTy); if (RHS == 0) return 0; if (Lex.getCode() != tgtok::r_paren) { Index: test/TableGen/if-empty-list-arg.td =================================================================== --- /dev/null +++ test/TableGen/if-empty-list-arg.td @@ -0,0 +1,6 @@ +// RUN: llvm-tblgen %s +// XFAIL: vg_leak + +class C { + list X = !if(cond, [1, 2, 3], []); +}