[PATCH] D43555: TableGen: Fix type deduction for !foreach
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 22 07:28:53 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325797: TableGen: Fix type deduction for !foreach (authored by nha, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D43555
Files:
llvm/trunk/lib/TableGen/TGParser.cpp
llvm/trunk/test/TableGen/foreach.td
Index: llvm/trunk/test/TableGen/foreach.td
===================================================================
--- llvm/trunk/test/TableGen/foreach.td
+++ llvm/trunk/test/TableGen/foreach.td
@@ -7,12 +7,18 @@
// CHECK: "NAME"
// CHECK: Defs
+
+// CHECK: def DX {
+// CHECK: list<string> x = ["0", "1", "2"];
+// CHECK: }
+
// CHECK: Jr
// CHECK: Sr
// Variables for foreach
class decls {
string name;
+ int num;
}
def Decls : decls;
@@ -37,3 +43,9 @@
def Juniors : C<People.values>;
def Smiths : D<["NAME", "Jane Smith"]>;
def Unprocessed : D<People.values>;
+
+class X<list<int> a> {
+ list<string> x = !foreach(Decls.num, a, !cast<string>(Decls.num));
+}
+
+def DX : X<[0, 1, 2]>;
Index: llvm/trunk/lib/TableGen/TGParser.cpp
===================================================================
--- llvm/trunk/lib/TableGen/TGParser.cpp
+++ llvm/trunk/lib/TableGen/TGParser.cpp
@@ -1075,6 +1075,14 @@
return nullptr;
}
Type = MHSt->getType();
+ if (isa<ListRecTy>(Type)) {
+ TypedInit *RHSt = dyn_cast<TypedInit>(RHS);
+ if (!RHSt) {
+ TokError("could not get type of !foreach list elements");
+ return nullptr;
+ }
+ Type = RHSt->getType()->getListTy();
+ }
break;
}
case tgtok::XSubst: {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43555.135420.patch
Type: text/x-patch
Size: 1311 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180222/c905f448/attachment.bin>
More information about the llvm-commits
mailing list