[llvm] [TableGen] Remove explicit recursion in LexToken (PR #143697)

Jason Eckhardt via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 11 07:49:50 PDT 2025


================
@@ -188,12 +189,12 @@ tgtok::TokKind TGLexer::LexToken(bool FileOrLineStart) {
     return ReturnError(TokStart, "unexpected character");
   case EOF:
     // Lex next token, if we just left an include file.
-    // Note that leaving an include file means that the next
-    // symbol is located at the end of the 'include "..."'
-    // construct, so LexToken() is called with default
-    // false parameter.
-    if (processEOF())
-      return LexToken();
+    if (processEOF()) {
+      // Leaving an include file means that the next symbol is located at the
+      // end of the 'include "..."'  construct.
+      FileOrLineStart = false;
+      goto restart;
+    }
----------------
nvjle wrote:

Instead of `goto`, might it be a bit cleaner to wrap this `switch` in a `while (true)`, similar to `SkipCComment`?

https://github.com/llvm/llvm-project/pull/143697


More information about the llvm-commits mailing list