This is an archive of the discontinued LLVM Phabricator instance.

[lldb][DataFormatter] Fix libcxx std::deque formatter for references and pointers
ClosedPublic

Authored by Michael137 on Apr 17 2023, 7:09 AM.

Details

Summary

(Addresses GH#62153)

The SBType APIs to retrieve details about template arguments,
such as GetTemplateArgumentType or GetTemplateArgumentKind
don't "desugar" LValueReferences/RValueReferences or pointers.
So when we try to format a std::deque&, the python call to
GetTemplateArgumentType fails to get a type, leading to
an element_size of 0 and a division-by-zero python exception
(which gets caught by the summary provider silently). This leads
to the contents of such std::deque& to be printed incorrectly.

This patch dereferences the reference/pointer before calling
into the above SBAPIs.

Testing

  • Add API test

Diff Detail

Event Timeline

Michael137 created this revision.Apr 17 2023, 7:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 17 2023, 7:09 AM
Michael137 requested review of this revision.Apr 17 2023, 7:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 17 2023, 7:09 AM
aprantl accepted this revision.Apr 17 2023, 11:21 AM
This revision is now accepted and ready to land.Apr 17 2023, 11:21 AM