[PATCH] D44115: TableGen: Explicitly forbid some nestings of class, multiclass, and foreach

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


nhaehnle created this revision.
nhaehnle added reviewers: arsenm, craig.topper, tra, MartinO.
Herald added a subscriber: wdng.

These previously all failed one way or another, but now we produce a more
helpful error message.

Change-Id: I8ffd2e87c8e35a5134c3be289e0a1fecaa2bb8ca


Repository:
  rL LLVM

https://reviews.llvm.org/D44115

Files:
  lib/TableGen/TGParser.cpp


Index: lib/TableGen/TGParser.cpp
===================================================================
--- lib/TableGen/TGParser.cpp
+++ lib/TableGen/TGParser.cpp
@@ -3134,8 +3134,16 @@
     if (MC)
       return TokError("defset is not allowed inside multiclass");
     return ParseDefset();
-  case tgtok::Class: return ParseClass();
-  case tgtok::MultiClass: return ParseMultiClass();
+  case tgtok::Class:
+    if (MC)
+      return TokError("class is not allowed inside multiclass");
+    if (!Loops.empty())
+      return TokError("class is not allowed inside foreach loop");
+    return ParseClass();
+  case tgtok::MultiClass:
+    if (!Loops.empty())
+      return TokError("multiclass is not allowed inside foreach loop");
+    return ParseMultiClass();
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44115.137063.patch
Type: text/x-patch
Size: 773 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180305/c7760c54/attachment.bin>


More information about the llvm-commits mailing list