This is an archive of the discontinued LLVM Phabricator instance.

[formatters] Add a formatter for libstdc++ optional

Authored by wallace on Nov 22 2021, 3:33 PM.



Besides adding the formatter and the summary, this makes the libcxx
tests also work for this case.

This is the polished version of,
authored by Danil Stefaniuc.

Diff Detail

Event Timeline

wallace requested review of this revision.Nov 22 2021, 3:33 PM
wallace created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptNov 22 2021, 3:33 PM
danilashtefan accepted this revision.Nov 22 2021, 3:34 PM
This revision is now accepted and ready to land.Nov 22 2021, 3:34 PM
This revision was landed with ongoing or failed builds.Nov 22 2021, 3:36 PM
This revision was automatically updated to reflect the committed changes.
labath added a subscriber: labath.Nov 23 2021, 2:24 AM

I'm seeing some very funky behavior after this patch. My machine has both libc++ and libstdc++, so both versions of this test run normally, and then libstdc++ fails. If I run just the libstdc++ version then it passes just fine. If I change the test order so that the libstdc++ version is run first, then the *libc++* version fails instead...


I assume this is relying on the fact that _M_engaged can only contain values 1 and 0. While this may be true for normal situations, people tend to use debuggers precisely in the situations where things are not "normal". And it'd be good if e.g. a user's memory corruption bug (which for example overwrites this field) does not make the debugger go haywire. You most likely cannot format the value correctly if that happens, but you can at least avoid printing 3195786238 children in those cases.
One way to do that would be to rename this field to engaged and implement the num_children method as return self.engaged ? 1 : 0