This is an archive of the discontinued LLVM Phabricator instance.

[Support] Make support types more easily printable.
ClosedPublic

Authored by sammccall on Jul 5 2018, 5:46 AM.

Details

Summary

formatv() can now print objects with a operator<< accepting raw_ostream.
This covers a bunch of new types, and avoids needing a dependency between formatv and the type when no special formatting options are needed.
(Maybe formatv deliberately doesn't do this today?)

Error's new operator<< is the first way to print an error without consuming it, which allows it to work with formatv.

Diff Detail

Repository
rL LLVM

Event Timeline

sammccall created this revision.Jul 5 2018, 5:46 AM
sammccall updated this revision to Diff 154254.Jul 5 2018, 9:26 AM

Simplify approach, just allow printing anything with operator<< as a fallback.
This reduces coupling and makes more types printable (proved useful/necessary for clangd logging refactor).

sammccall updated this revision to Diff 154255.Jul 5 2018, 9:31 AM

Remove noisy changes, add Error test.

sammccall retitled this revision from [Support] Make Error and formatv_object_base printable with formatv(). to [Support] Make support types more easily printable..Jul 5 2018, 9:35 AM
sammccall edited the summary of this revision. (Show Details)
sammccall added a reviewer: zturner.
zturner accepted this revision.Jul 5 2018, 10:03 AM
zturner added inline comments.
unittests/Support/ErrorTest.cpp
733 ↗(On Diff #154255)

Is the space supposed to be before the 0?

This revision is now accepted and ready to land.Jul 5 2018, 10:03 AM
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
sammccall added inline comments.Jul 5 2018, 11:18 PM
unittests/Support/ErrorTest.cpp
733 ↗(On Diff #154255)

Hmm, this was in the existing test helpers but it just looks like a typo. Fixed in various places.