[PATCH] Fix error in tablegen when second operand of an !if is an empty list.
Matt Arsenault
Matthew.Arsenault at amd.com
Fri May 30 22:24:25 PDT 2014
Replace with a simpler fix that also handles an empty list as either result operand
http://reviews.llvm.org/D2724
Files:
lib/TableGen/TGParser.cpp
lib/TableGen/TGParser.h
test/TableGen/if-empty-list-arg.td
Index: lib/TableGen/TGParser.cpp
===================================================================
--- lib/TableGen/TGParser.cpp
+++ lib/TableGen/TGParser.cpp
@@ -782,7 +782,7 @@
///
/// Operation ::= XOperator ['<' Type '>'] '(' Args ')'
///
-Init *TGParser::ParseOperation(Record *CurRec) {
+Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) {
switch (Lex.getCode()) {
default:
TokError("unknown operation");
@@ -1021,17 +1021,19 @@
}
Lex.Lex(); // eat the ','
- Init *MHS = ParseValue(CurRec);
- if (!MHS) return nullptr;
+ Init *MHS = ParseValue(CurRec, ItemType);
+ if (!MHS)
+ return nullptr;
if (Lex.getCode() != tgtok::comma) {
TokError("expected ',' in ternary operator");
return nullptr;
}
Lex.Lex(); // eat the ','
- Init *RHS = ParseValue(CurRec);
- if (!RHS) return nullptr;
+ Init *RHS = ParseValue(CurRec, ItemType);
+ if (!RHS)
+ return nullptr;
if (Lex.getCode() != tgtok::r_paren) {
TokError("expected ')' in binary operator");
@@ -1441,7 +1443,7 @@
case tgtok::XIf:
case tgtok::XForEach:
case tgtok::XSubst: { // Value ::= !ternop '(' Value ',' Value ',' Value ')'
- return ParseOperation(CurRec);
+ return ParseOperation(CurRec, ItemType);
}
}
Index: lib/TableGen/TGParser.h
===================================================================
--- lib/TableGen/TGParser.h
+++ lib/TableGen/TGParser.h
@@ -181,7 +181,7 @@
std::vector<unsigned> ParseRangeList();
bool ParseRangePiece(std::vector<unsigned> &Ranges);
RecTy *ParseType();
- Init *ParseOperation(Record *CurRec);
+ Init *ParseOperation(Record *CurRec, RecTy *ItemType);
RecTy *ParseOperatorType();
Init *ParseObjectName(MultiClass *CurMultiClass);
Record *ParseClassID();
Index: test/TableGen/if-empty-list-arg.td
===================================================================
--- /dev/null
+++ test/TableGen/if-empty-list-arg.td
@@ -0,0 +1,7 @@
+// RUN: llvm-tblgen %s
+// XFAIL: vg_leak
+
+class C<bit cond> {
+ list<int> X = !if(cond, [1, 2, 3], []);
+ list<int> Y = !if(cond, [], [4, 5, 6]);
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2724.9979.patch
Type: text/x-patch
Size: 2154 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140531/b08ef0c4/attachment.bin>
More information about the llvm-commits
mailing list