Implement a !foreach operator analogous to GNU make's $(foreach).
Use it on dags and lists like this:

class decls {
  string name;
}

def Decls : decls;

class B<list<string> names> : A<!foreach(Decls.name, names, !strconcat(Decls.name, ", Sr."))>;


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71803 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/utils/TableGen/TGParser.cpp b/utils/TableGen/TGParser.cpp
index 967f5d0..bc5d65e 100644
--- a/utils/TableGen/TGParser.cpp
+++ b/utils/TableGen/TGParser.cpp
@@ -792,7 +792,7 @@
     return (new BinOpInit(Code, LHS, RHS, Type))->Fold(CurRec, CurMultiClass);
   }
 
-//   case tgtok::XForEach:
+  case tgtok::XForEach:
   case tgtok::XSubst: {  // Value ::= !ternop '(' Value ',' Value ',' Value ')'
     TernOpInit::TernaryOp Code;
     RecTy *Type = 0;
@@ -802,9 +802,9 @@
     Lex.Lex();  // eat the operation
     switch (LexCode) {
     default: assert(0 && "Unhandled code!");
-      //case tgtok::XForEach:
-      //Code = TernOpInit::FOREACH;
-      //break;
+    case tgtok::XForEach:
+      Code = TernOpInit::FOREACH;
+      break;
     case tgtok::XSubst:
       Code = TernOpInit::SUBST;
       break;
@@ -844,15 +844,15 @@
 
     switch (LexCode) {
     default: assert(0 && "Unhandled code!");
-      //case tgtok::XForEach: {
-      //TypedInit *MHSt = dynamic_cast<TypedInit *>(MHS);
-      //if (MHSt == 0) {
-      //  TokError("could not get type for !foreach");
-      //  return 0;
-      //}
-      //Type = MHSt->getType();
-      //break;
-      //}
+    case tgtok::XForEach: {
+      TypedInit *MHSt = dynamic_cast<TypedInit *>(MHS);
+      if (MHSt == 0) {
+        TokError("could not get type for !foreach");
+        return 0;
+      }
+      Type = MHSt->getType();
+      break;
+    }
     case tgtok::XSubst: {
       TypedInit *RHSt = dynamic_cast<TypedInit *>(RHS);
       if (RHSt == 0) {
@@ -1079,7 +1079,7 @@
   case tgtok::XSHL:
   case tgtok::XStrConcat:
   case tgtok::XNameConcat:  // Value ::= !binop '(' Value ',' Value ')'
-    //  case tgtok::XForEach:
+  case tgtok::XForEach:
   case tgtok::XSubst: {  // Value ::= !ternop '(' Value ',' Value ',' Value ')'
     return ParseOperation(CurRec);
     break;