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.

The code was written to handle nullable grammar, and we disallow
nullable grammar, so it is not necessary to keep it around.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124827

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


Index: clang-tools-extra/pseudo/lib/Forest.cpp
===================================================================
--- clang-tools-extra/pseudo/lib/Forest.cpp
+++ clang-tools-extra/pseudo/lib/Forest.cpp
@@ -74,16 +74,13 @@
         } else if (P->kind() == Sequence) {
           Children = P->elements();
           if (Abbreviated) {
-            if (P->startTokenIndex() == End)
-              return;
-            for (size_t I = 0; I < Children.size(); ++I)
-              if (Children[I]->startTokenIndex() == P->startTokenIndex() &&
-                  EndOfElement(I) == End) {
-                return Dump(
-                    Children[I], End,
-                    /*ElidedParent=*/ElidedParent.getValueOr(P->symbol()),
-                    LineDec);
-              }
+            if (Children.size() == 1) {
+              assert(Children[0]->startTokenIndex() == P->startTokenIndex() &&
+                     EndOfElement(0) == End);
+              return Dump(Children[0], End,
+                          
/*ElidedParent=*/ElidedParent.getValueOr(P->symbol()),
+                          LineDec);
+            }
           }
         }
 


Index: clang-tools-extra/pseudo/lib/Forest.cpp
===================================================================
--- clang-tools-extra/pseudo/lib/Forest.cpp
+++ clang-tools-extra/pseudo/lib/Forest.cpp
@@ -74,16 +74,13 @@
         } else if (P->kind() == Sequence) {
           Children = P->elements();
           if (Abbreviated) {
-            if (P->startTokenIndex() == End)
-              return;
-            for (size_t I = 0; I < Children.size(); ++I)
-              if (Children[I]->startTokenIndex() == P->startTokenIndex() &&
-                  EndOfElement(I) == End) {
-                return Dump(
-                    Children[I], End,
-                    /*ElidedParent=*/ElidedParent.getValueOr(P->symbol()),
-                    LineDec);
-              }
+            if (Children.size() == 1) {
+              assert(Children[0]->startTokenIndex() == P->startTokenIndex() &&
+                     EndOfElement(0) == End);
+              return Dump(Children[0], End,
+                          /*ElidedParent=*/ElidedParent.getValueOr(P->symbol()),
+                          LineDec);
+            }
           }
         }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D124827: [pseudo] Simpl... Haojian Wu via Phabricator via cfe-commits

Reply via email to