[llvm] r210572 - Fix error in tablegen when either operand of !if is an empty list.

Matt Arsenault Matthew.Arsenault at amd.com
Tue Jun 10 13:10:09 PDT 2014


Author: arsenm
Date: Tue Jun 10 15:10:08 2014
New Revision: 210572

URL: http://llvm.org/viewvc/llvm-project?rev=210572&view=rev
Log:
Fix error in tablegen when either operand of !if is an empty list.

!if([Something], []) would error with "No type for list".

Added:
    llvm/trunk/test/TableGen/if-empty-list-arg.td
Modified:
    llvm/trunk/lib/TableGen/TGParser.cpp
    llvm/trunk/lib/TableGen/TGParser.h

Modified: llvm/trunk/lib/TableGen/TGParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=210572&r1=210571&r2=210572&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/TGParser.cpp (original)
+++ llvm/trunk/lib/TableGen/TGParser.cpp Tue Jun 10 15:10:08 2014
@@ -787,7 +787,7 @@ Init *TGParser::ParseIDValue(Record *Cur
 ///
 /// Operation ::= XOperator ['<' Type '>'] '(' Args ')'
 ///
-Init *TGParser::ParseOperation(Record *CurRec) {
+Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) {
   switch (Lex.getCode()) {
   default:
     TokError("unknown operation");
@@ -1026,8 +1026,9 @@ Init *TGParser::ParseOperation(Record *C
     }
     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");
@@ -1035,8 +1036,9 @@ Init *TGParser::ParseOperation(Record *C
     }
     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");
@@ -1446,7 +1448,7 @@ Init *TGParser::ParseSimpleValue(Record
   case tgtok::XIf:
   case tgtok::XForEach:
   case tgtok::XSubst: {  // Value ::= !ternop '(' Value ',' Value ',' Value ')'
-    return ParseOperation(CurRec);
+    return ParseOperation(CurRec, ItemType);
   }
   }
 

Modified: llvm/trunk/lib/TableGen/TGParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.h?rev=210572&r1=210571&r2=210572&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/TGParser.h (original)
+++ llvm/trunk/lib/TableGen/TGParser.h Tue Jun 10 15:10:08 2014
@@ -181,7 +181,7 @@ private:  // Parser methods.
   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();

Added: llvm/trunk/test/TableGen/if-empty-list-arg.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/if-empty-list-arg.td?rev=210572&view=auto
==============================================================================
--- llvm/trunk/test/TableGen/if-empty-list-arg.td (added)
+++ llvm/trunk/test/TableGen/if-empty-list-arg.td Tue Jun 10 15:10:08 2014
@@ -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]);
+}





More information about the llvm-commits mailing list