Author: Haojian Wu Date: 2022-05-03T14:14:57+02:00 New Revision: b18abde8ada122408724d2a1722aa2f75e9a87ce
URL: https://github.com/llvm/llvm-project/commit/b18abde8ada122408724d2a1722aa2f75e9a87ce DIFF: https://github.com/llvm/llvm-project/commit/b18abde8ada122408724d2a1722aa2f75e9a87ce.diff LOG: [pseudo] Simplify the forest dump, NFC. The code was written to handle nullable grammar, and we disallow nullable grammar, so it is not necessary to keep it around. Differential Revision: https://reviews.llvm.org/D124827 Added: Modified: clang-tools-extra/pseudo/lib/Forest.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/pseudo/lib/Forest.cpp b/clang-tools-extra/pseudo/lib/Forest.cpp index 6948422a23a6e..073a651947ac4 100644 --- a/clang-tools-extra/pseudo/lib/Forest.cpp +++ b/clang-tools-extra/pseudo/lib/Forest.cpp @@ -74,16 +74,13 @@ std::string ForestNode::dumpRecursive(const Grammar &G, } 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