[llvm] r356986 - [TableGen] Let list elements have a trailing comma
Javed Absar via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 26 04:16:02 PDT 2019
Author: javed.absar
Date: Tue Mar 26 04:16:01 2019
New Revision: 356986
URL: http://llvm.org/viewvc/llvm-project?rev=356986&view=rev
Log:
[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
Modified:
llvm/trunk/lib/TableGen/TGParser.cpp
llvm/trunk/test/TableGen/ListArgs.td
Modified: llvm/trunk/lib/TableGen/TGParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=356986&r1=356985&r2=356986&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/TGParser.cpp (original)
+++ llvm/trunk/lib/TableGen/TGParser.cpp Tue Mar 26 04:16:01 2019
@@ -2283,6 +2283,10 @@ void TGParser::ParseValueList(SmallVecto
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()) {
Modified: llvm/trunk/test/TableGen/ListArgs.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/ListArgs.td?rev=356986&r1=356985&r2=356986&view=diff
==============================================================================
--- llvm/trunk/test/TableGen/ListArgs.td (original)
+++ llvm/trunk/test/TableGen/ListArgs.td Tue Mar 26 04:16:01 2019
@@ -10,3 +10,7 @@ class BBB<list<list<int>> vals> : BB<val
def OneB : BBB<[[1,2,3]]>;
def TwoB : BBB<[[1,2,3],[4,5,6]]>;
+
+def ThreeB: BBB<[[1,2,3],
+ [4,5,6],
+ ]>;
More information about the llvm-commits
mailing list