This is an archive of the discontinued LLVM Phabricator instance.

[gdb] Add pretty printer for Expected
ClosedPublic

Authored by MaskRay on Jun 22 2018, 5:19 PM.

Diff Detail

Event Timeline

MaskRay created this revision.Jun 22 2018, 5:19 PM

Thanks for adding to/improving the GDB pretty printer support! Just a few questions/thoughts to try to understand how this works similarly/differently from other related printers!

utils/gdb-scripts/prettyprinters.py
134

dereference() is done here, but not in the Optional pretty printer below - any idea if there's a reason for that inconsistency? (maybe they're implemented differently in a way that I'm missing/not understanding right now)

137

llvm::Optional pretty printer doesn't include the template argument (& neither does the built-in std::vector printer, I think?). Probably, for consistency & to avoid being overly verbose, do similarly here & skip the template argument?

MaskRay updated this revision to Diff 152790.Jun 25 2018, 3:27 PM

Make OptionalPrinter inherit from Iterator to remove boilerplate

MaskRay marked 2 inline comments as done.Jun 25 2018, 3:30 PM
dblaikie accepted this revision.Jun 25 2018, 3:49 PM

Still not quite sure why the change in implementation of Optional - what the difference is between how it was done & how it's done now/with this patch, etc. But I'm not too fussed - if it works for you :)

This revision is now accepted and ready to land.Jun 25 2018, 3:49 PM
MaskRay updated this revision to Diff 152799.Jun 25 2018, 4:26 PM

less verbose

This revision was automatically updated to reflect the committed changes.

Still not quite sure why the change in implementation of Optional - what the difference is between how it was done & how it's done now/with this patch, etc. But I'm not too fussed - if it works for you :)

I find the same trick is used in /usr/share/gcc-8/python/libstdcxx/v6/printers.py. The base class defines some boilerplate (__iter__, Python 2 compatible def next) so that the nested _iterator class can be flattened into the outer class.