From: Javed Absar Date: Tue, 26 Mar 2019 11:16:01 +0000 (+0000) Subject: [TableGen] Let list elements have a trailing comma X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2084b7bc1ca4729bc7b9c5b9a26170b5b8ed557;p=llvm [TableGen] Let list elements have a trailing comma Let lists have an trailing comma to allow cleaner diffs e.g: def : Features<[FeatureA, FeatureB, ]>; Reviewed By: hfinkel Differential Revision: https://reviews.llvm.org/D59247 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356986 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/TableGen/TGParser.cpp b/lib/TableGen/TGParser.cpp index 3fc2e53f208..f9486d4469d 100644 --- a/lib/TableGen/TGParser.cpp +++ b/lib/TableGen/TGParser.cpp @@ -2283,6 +2283,10 @@ void TGParser::ParseValueList(SmallVectorImpl &Result, Record *CurRec, while (Lex.getCode() == tgtok::comma) { Lex.Lex(); // Eat the comma + // ignore trailing comma for lists + if (Lex.getCode() == tgtok::r_square) + return; + if (ArgsRec && !EltTy) { ArrayRef TArgs = ArgsRec->getTemplateArgs(); if (ArgN >= TArgs.size()) { diff --git a/test/TableGen/ListArgs.td b/test/TableGen/ListArgs.td index 8714112d137..4d2713a1cab 100644 --- a/test/TableGen/ListArgs.td +++ b/test/TableGen/ListArgs.td @@ -10,3 +10,7 @@ class BBB> vals> : BB; def OneB : BBB<[[1,2,3]]>; def TwoB : BBB<[[1,2,3],[4,5,6]]>; + +def ThreeB: BBB<[[1,2,3], + [4,5,6], + ]>;