[PATCH] Fix error in tablegen when second operand of an !if is an empty list.

Matt Arsenault Matthew.Arsenault at amd.com
Fri Feb 7 15:00:47 PST 2014


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


http://llvm-reviews.chandlerc.com/D2724

Files:
  lib/TableGen/TGParser.cpp

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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2724.1.patch
Type: text/x-patch
Size: 618 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140207/3d5ed67e/attachment.bin>


More information about the llvm-commits mailing list