This is an archive of the discontinued LLVM Phabricator instance.

[pseudo] Placeholder disambiguation strategy: always choose second
ClosedPublic

Authored by sammccall on Aug 23 2022, 10:21 AM.

Details

Summary

Mostly mechanics here. Interesting decisions:

  • apply disambiguation in-place instead of copying the forest debatable, but even the final tree size is significant
  • split decide/apply into different functions - this allows the hard part (decide) to be tested non-destructively and combined with HTML forest easily
  • add non-const accessors to forest to enable apply
  • unit tests but no lit tests: my plan is to test actual C++ disambiguation heuristics with lit, generic disambiguation mechanics without the C++ grammar

Diff Detail

Event Timeline

sammccall created this revision.Aug 23 2022, 10:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2022, 10:21 AM
Herald added a subscriber: mgorny. · View Herald Transcript
sammccall requested review of this revision.Aug 23 2022, 10:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2022, 10:21 AM
hokein accepted this revision.Aug 23 2022, 2:09 PM

This looks a good start!

clang-tools-extra/pseudo/tool/ClangPseudo.cpp
232

nit: we're going to print the forest *and* the disambiguated tree, is that intended? IMO, if we specify the disambiguate flag, I'd not print the forest as well.

clang-tools-extra/pseudo/unittests/DisambiguateTest.cpp
29

nit: it seems like we write a lot of boilerplate code just for creating a Forest for a single a*b; case below, it is fine currently, but if we're going to add some more unittests , we might want an automate way to do that.

This revision is now accepted and ready to land.Aug 23 2022, 2:09 PM
sammccall marked an inline comment as done.Aug 26 2022, 4:10 AM
sammccall added inline comments.
clang-tools-extra/pseudo/tool/ClangPseudo.cpp
232

I guess you're right. My use case was debugging disambiguation with -print-forest -disambiguate -debug=only=Disambiguate.cpp - I think we need the before + after + log.

However we can log the "before" with LLVM_DEBUG() inside disambiguate() instead.

clang-tools-extra/pseudo/unittests/DisambiguateTest.cpp
29

Hmm, maybe. It's not obvious to me that you can do much better (other approaches have tradeoffs, e.g. I think having all the nodes/rules/symbols as named variables is clearer than what we've done in some other places, and I think depending on the C++ grammar would confuse things).

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