[PATCH] D59247: [TableGen] Let list elements have a trailing comma
Javed Absar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 12 04:28:37 PDT 2019
javed.absar created this revision.
javed.absar added reviewers: eli.friedman, nhaehnle, simon_tatham, hfinkel.
Let lists have an trailing comma to allow cleaner diffs e.g:
def : Features<[FeatureA,
FeatureB,
]>;
I could extend it to template arguments, if there is enough consensus on it.
https://reviews.llvm.org/D59247
Files:
lib/TableGen/TGParser.cpp
test/TableGen/ListArgs.td
Index: test/TableGen/ListArgs.td
===================================================================
--- test/TableGen/ListArgs.td
+++ test/TableGen/ListArgs.td
@@ -10,3 +10,7 @@
def OneB : BBB<[[1,2,3]]>;
def TwoB : BBB<[[1,2,3],[4,5,6]]>;
+
+def ThreeB: BBB<[[1,2,3],
+ [4,5,6],
+ ]>;
Index: lib/TableGen/TGParser.cpp
===================================================================
--- lib/TableGen/TGParser.cpp
+++ lib/TableGen/TGParser.cpp
@@ -2277,6 +2277,10 @@
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()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59247.190235.patch
Type: text/x-patch
Size: 810 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190312/95712dbe/attachment.bin>
More information about the llvm-commits
mailing list