diff --git a/lib/TableGen/TGParser.cpp b/lib/TableGen/TGParser.cpp index 81c68292f1b..9ed7ebbb6bd 100644 --- a/lib/TableGen/TGParser.cpp +++ b/lib/TableGen/TGParser.cpp @@ -1516,6 +1516,10 @@ std::vector TGParser::ParseValueList(Record *CurRec, Record *ArgsRec, unsigned int ArgN = 0; if (ArgsRec != 0 && EltTy == 0) { const std::vector &TArgs = ArgsRec->getTemplateArgs(); + if (!TArgs.size()) { + TokError("template argument provided to non-template class"); + return std::vector(); + } const RecordVal *RV = ArgsRec->getValue(TArgs[ArgN]); if (!RV) { errs() << "Cannot find template arg " << ArgN << " (" << TArgs[ArgN]