[PATCH] D44107: TableGen: Remove unused ParseForeachMode

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 5 12:20:35 PST 2018


nhaehnle created this revision.
nhaehnle added reviewers: arsenm, craig.topper, tra, MartinO.
Herald added a subscriber: wdng.
nhaehnle added a dependency: D44106: TableGen: More helpful error messages.
nhaehnle added a dependent revision: D44108: TableGen: Allow arbitrary list values as ranges of foreach.

Use the default ParseValueMode instead of ParseForeachMode when
parsing the rule

  ForeachDeclaration ::= ID '=' '[' ValueList ']'

because the only difference between the two is how an open brace '{'
is handled at the end. In the context of foreach, the 'in' keyword
will appear after the ForeachDeclaration, so this special handling
of '{' is not required.

Change-Id: I4d86bb73bab9ec26752e1273e5213df77cf28d1d


Repository:
  rL LLVM

https://reviews.llvm.org/D44107

Files:
  lib/TableGen/TGParser.cpp
  lib/TableGen/TGParser.h


Index: lib/TableGen/TGParser.h
===================================================================
--- lib/TableGen/TGParser.h
+++ lib/TableGen/TGParser.h
@@ -77,7 +77,6 @@
     ParseValueMode,   // We are parsing a value we expect to look up.
     ParseNameMode,    // We are parsing a name of an object that does not yet
                       // exist.
-    ParseForeachMode  // We are parsing a foreach init.
   };
 
 public:
Index: lib/TableGen/TGParser.cpp
===================================================================
--- lib/TableGen/TGParser.cpp
+++ lib/TableGen/TGParser.cpp
@@ -1759,7 +1759,7 @@
     switch (Lex.getCode()) {
     default: return Result;
     case tgtok::l_brace: {
-      if (Mode == ParseNameMode || Mode == ParseForeachMode)
+      if (Mode == ParseNameMode)
         // This is the beginning of the object body.
         return Result;
 
@@ -2062,7 +2062,7 @@
   switch (Lex.getCode()) {
   default: TokError("Unknown token when expecting a range list"); return nullptr;
   case tgtok::l_square: { // '[' ValueList ']'
-    Init *List = ParseSimpleValue(nullptr, nullptr, ParseForeachMode);
+    Init *List = ParseSimpleValue(nullptr);
     ForeachListValue = dyn_cast<ListInit>(List);
     if (!ForeachListValue) {
       TokError("Expected a Value list");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44107.137055.patch
Type: text/x-patch
Size: 1296 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180305/12f93d36/attachment.bin>


More information about the llvm-commits mailing list