This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Refine call to decl printing helper (NFC)
ClosedPublic

Authored by kastiglione on May 8 2023, 10:34 AM.

Details

Summary

When ValueObjectPrinter calls its m_decl_printing_helper, not all state is passed to
the helper. In particular, the helper doesn't have access to m_curr_depth, and thus
can't act on the logic within ShouldShowName.

To address this, this change passes in a modified copy of m_options. The modified copy
has has m_hide_name set according to the results of ShouldShowName. This allows
helper functions to know whether the name should be shown or hidden, without having
access to ValueObjectPrinter's full state.

This is NFC in mainline lldb, as the only decl printing helper doesn't make use of this.
However in swift-lldb at least, there are decl printing helpers that do need this
information passed to them. See https://github.com/apple/llvm-project/pull/6795 where a
test is also included.

Diff Detail

Event Timeline

kastiglione created this revision.May 8 2023, 10:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 8 2023, 10:34 AM
kastiglione requested review of this revision.May 8 2023, 10:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 8 2023, 10:34 AM
aprantl accepted this revision.May 8 2023, 10:59 AM
This revision is now accepted and ready to land.May 8 2023, 10:59 AM
This revision was automatically updated to reflect the committed changes.