]> granicus.if.org Git - llvm/commitdiff
[TableGen] Let list elements have a trailing comma
authorJaved Absar <javed.absar@arm.com>
Tue, 26 Mar 2019 11:16:01 +0000 (11:16 +0000)
committerJaved Absar <javed.absar@arm.com>
Tue, 26 Mar 2019 11:16:01 +0000 (11:16 +0000)
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

lib/TableGen/TGParser.cpp
test/TableGen/ListArgs.td

index 3fc2e53f208a8f31527b6cea3685b48bc6a24a43..f9486d4469d0b4883e665953a42144f9263e87dc 100644 (file)
@@ -2283,6 +2283,10 @@ void TGParser::ParseValueList(SmallVectorImpl<Init*> &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<Init *> TArgs = ArgsRec->getTemplateArgs();
       if (ArgN >= TArgs.size()) {
index 8714112d137b2c84469751ae7e73c93e38c3cfc1..4d2713a1cabbc7e83d4965e9a146f091458f90d4 100644 (file)
@@ -10,3 +10,7 @@ class BBB<list<list<int>> vals> : BB<vals>;
 
 def OneB : BBB<[[1,2,3]]>;
 def TwoB : BBB<[[1,2,3],[4,5,6]]>;
+
+def ThreeB: BBB<[[1,2,3],
+                 [4,5,6],
+                ]>;