[PATCH] Fix error in tablegen when second operand of an !if is an empty list.
Matt Arsenault
Matthew.Arsenault at amd.com
Tue Feb 18 16:18:42 PST 2014
Add test. I didn't know there were any tests for tablegen before.
http://llvm-reviews.chandlerc.com/D2724
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D2724?vs=6946&id=7192#toc
Files:
lib/TableGen/TGParser.cpp
test/TableGen/if-empty-list-arg.td
Index: lib/TableGen/TGParser.cpp
===================================================================
--- lib/TableGen/TGParser.cpp
+++ lib/TableGen/TGParser.cpp
@@ -1028,7 +1028,13 @@
}
Lex.Lex(); // eat the ','
- Init *RHS = ParseValue(CurRec);
+ // Get the type in case the second operand might be an empty list. We can
+ // infer the next item's type is the same.
+ RecTy *MHSTy = 0;
+ if (TypedInit *MHSt = dyn_cast<TypedInit>(MHS))
+ MHSTy = MHSt->getType();
+
+ Init *RHS = ParseValue(CurRec, MHSTy);
if (RHS == 0) return 0;
if (Lex.getCode() != tgtok::r_paren) {
Index: test/TableGen/if-empty-list-arg.td
===================================================================
--- /dev/null
+++ test/TableGen/if-empty-list-arg.td
@@ -0,0 +1,6 @@
+// RUN: llvm-tblgen %s
+// XFAIL: vg_leak
+
+class C<bit cond> {
+ list<int> X = !if(cond, [1, 2, 3], []);
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2724.2.patch
Type: text/x-patch
Size: 909 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140218/d3f2cc6c/attachment.bin>
More information about the llvm-commits
mailing list