From 1ddb78cd5f13756cdf6718c3aa688447b6b70aeb Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Mon, 5 Dec 2016 06:41:51 +0000 Subject: TableGen/Record: Replace std::vector with SmallVector/ArrayRef llvm-svn: 288648 --- llvm/lib/TableGen/TGParser.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'llvm/lib/TableGen/TGParser.cpp') diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp index 690cbf929c8..b342f624295 100644 --- a/llvm/lib/TableGen/TGParser.cpp +++ b/llvm/lib/TableGen/TGParser.cpp @@ -1428,9 +1428,9 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType, Lex.Lex(); // eat the VarName. } - std::vector > DagArgs; + SmallVector, 8> DagArgs; if (Lex.getCode() != tgtok::r_paren) { - DagArgs = ParseDagArgList(CurRec); + ParseDagArgList(DagArgs, CurRec); if (DagArgs.empty()) return nullptr; } @@ -1603,9 +1603,9 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType, IDParseMode Mode) { /// DagArg ::= VARNAME /// DagArgList ::= DagArg /// DagArgList ::= DagArgList ',' DagArg -std::vector > -TGParser::ParseDagArgList(Record *CurRec) { - std::vector > Result; +void TGParser::ParseDagArgList( + SmallVectorImpl> &Result, + Record *CurRec) { while (true) { // DagArg ::= VARNAME @@ -1617,15 +1617,18 @@ TGParser::ParseDagArgList(Record *CurRec) { } else { // DagArg ::= Value (':' VARNAME)? Init *Val = ParseValue(CurRec); - if (!Val) - return std::vector >(); + if (!Val) { + Result.clear(); + return; + } // If the variable name is present, add it. StringInit *VarName = nullptr; if (Lex.getCode() == tgtok::colon) { if (Lex.Lex() != tgtok::VarName) { // eat the ':' TokError("expected variable name in dag literal"); - return std::vector >(); + Result.clear(); + return; } VarName = StringInit::get(Lex.getCurStrVal()); Lex.Lex(); // eat the VarName. @@ -1636,8 +1639,6 @@ TGParser::ParseDagArgList(Record *CurRec) { if (Lex.getCode() != tgtok::comma) break; Lex.Lex(); // eat the ',' } - - return Result; } /// ParseValueList - Parse a comma separated list of values, returning them as a -- cgit v1.2.3