This is an archive of the discontinued LLVM Phabricator instance.

[pseudo] Fix bugs/inconsistencies in forest dump.
ClosedPublic

Authored by sammccall on Jun 29 2022, 4:38 AM.

Details

Summary
  • when printing a shared node for the second time, don't print its children (This keeps output proportional to the size of the structure)
  • when printing a shared node for the second time, print its type only, not rule (for consistency with above: don't dump details of nodes twice)
  • don't abbreviate shared nodes, to ensure we can prune the tree there

Diff Detail

Event Timeline

sammccall created this revision.Jun 29 2022, 4:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2022, 4:38 AM
sammccall requested review of this revision.Jun 29 2022, 4:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2022, 4:38 AM
hokein accepted this revision.Jun 29 2022, 6:32 AM
hokein added inline comments.
clang-tools-extra/pseudo/unittests/ForestTest.cpp
138

I was confused by the forest here -- the fact that it doesn't reflect the grammar (I was trying to figure out why there is an ambiguous node for A by reading the grammar above)

I think there should be a comment clarifying the gap between the grammar and forest -- this is an artificial forest which is only for testing the dump purpose -- we only need the symbol bits from the grammar (I actual think GLRTest::buildGrammar is a better fit for the tests in this file).

This revision is now accepted and ready to land.Jun 29 2022, 6:32 AM
sammccall marked an inline comment as done.Jun 29 2022, 1:56 PM
sammccall added inline comments.
clang-tools-extra/pseudo/unittests/ForestTest.cpp
138

This forest does matches the grammar, unless I'm missing something.
It has imperfect sharing (two nodes with the same rule+range), but strictly it's our GLR parser that guarantees perfect sharing, not the forest itself.

Added a comment.

This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.