[PATCH] D125481: [pseudo] NFC, bail out the parse loop if there is no active heads.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 12 10:41:37 PDT 2022


hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: All.
hokein requested review of this revision.
Herald added a subscriber: alextsao1999.
Herald added a project: clang-tools-extra.

And print the line number in the debug message, which makes it easier to
locate the position where we fail to parse.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125481

Files:
  clang-tools-extra/pseudo/lib/GLR.cpp


Index: clang-tools-extra/pseudo/lib/GLR.cpp
===================================================================
--- clang-tools-extra/pseudo/lib/GLR.cpp
+++ clang-tools-extra/pseudo/lib/GLR.cpp
@@ -65,9 +65,14 @@
       GSS.addNode(/*State=*/Params.Table.getStartState(Target),
                   /*ForestNode=*/nullptr, {})};
   for (const ForestNode &Terminal : Terminals) {
-    LLVM_DEBUG(llvm::dbgs() << llvm::formatv("Next token {0} (id={1})\n",
-                                             G.symbolName(Terminal.symbol()),
-                                             Terminal.symbol()));
+    LLVM_DEBUG(llvm::dbgs() << llvm::formatv(
+                   "Next token {0} (id={1}, line={2})\n",
+                   G.symbolName(Terminal.symbol()), Terminal.symbol(),
+                   Tokens.tokens()[Terminal.startTokenIndex()].Line + 1));
+    // No active heads, we fail to parse the input, bail out.
+    if (NewHeads.empty())
+      break;
+
     for (const auto *Head : NewHeads)
       AddSteps(Head, Terminal.symbol());
     NewHeads.clear();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125481.429003.patch
Type: text/x-patch
Size: 1062 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220512/b8fea96e/attachment.bin>


More information about the cfe-commits mailing list