From dbba016f7b534f56c194f3fb1bf837a320b57ae3 Mon Sep 17 00:00:00 2001 From: David Greene Date: Mon, 29 Jun 2009 19:59:52 +0000 Subject: [PATCH] Improve TableGen error reporting. llvm-svn: 74443 --- utils/TableGen/TGParser.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/utils/TableGen/TGParser.cpp b/utils/TableGen/TGParser.cpp index 28ebdb58c0f..1109defb75e 100644 --- a/utils/TableGen/TGParser.cpp +++ b/utils/TableGen/TGParser.cpp @@ -1395,7 +1395,7 @@ TGParser::ParseDagArgList(Record *CurRec) { std::vector TGParser::ParseValueList(Record *CurRec, Record *ArgsRec, RecTy *EltTy) { std::vector Result; RecTy *ItemType = EltTy; - int ArgN = 0; + unsigned int ArgN = 0; if (ArgsRec != 0 && EltTy == 0) { const std::vector &TArgs = ArgsRec->getTemplateArgs(); const RecordVal *RV = ArgsRec->getValue(TArgs[ArgN]); @@ -1411,6 +1411,10 @@ std::vector TGParser::ParseValueList(Record *CurRec, Record *ArgsRec, Rec if (ArgsRec != 0 && EltTy == 0) { const std::vector &TArgs = ArgsRec->getTemplateArgs(); + if (ArgN >= TArgs.size()) { + TokError("too many template arguments"); + return std::vector(); + } const RecordVal *RV = ArgsRec->getValue(TArgs[ArgN]); assert(RV && "Template argument record not found??"); ItemType = RV->getType();