[Lldb-commits] [PATCH] D114450: Improve optional formatter
Pavel Labath via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Nov 23 10:32:59 PST 2021
labath added a comment.
In D114450#3149281 <https://reviews.llvm.org/D114450#3149281>, @wallace wrote:
>> That said, I'm more worried about the strange interactions between libc++ and libstdc++ formatters I reported.
>
> yes, I'm trying to install libc++ on my machine now
Cool, thanks.
================
Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:24
self.value = self.payload.GetChildMemberWithName('_M_payload')
- self.count = self.payload.GetChildMemberWithName('_M_engaged').GetValueAsUnsigned(0)
+ self.has_value = self.payload.GetChildMemberWithName('_M_engaged').GetValueAsUnsigned(0) == 1
except:
----------------
wallace wrote:
> labath wrote:
> > I'd use `!= 0`, as matches what the actual implementation would do in this case.
> If that's true, then I'd need to update the libcxx formatter. My understanding is that setting something to true is always compiled as `set to 1`, or am I wrong?
You are correct. However, _checking_ whether something is true is normally implemented as `!= 0`.
This doesn't make a difference for the normal case, but in the "corrupted" case it might be a bit confusing that the program will report the optional object as "engaged", but we will say it's empty. It's not a big deal though.
I also wouldn't say you need to change the libc++ formatter too (though I won't stop you from doing it). If you really care about keeping the two in sync, I'd recommend making a unified implementation for the two (that might also probably fix the ordering problem).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114450/new/
https://reviews.llvm.org/D114450
More information about the lldb-commits
mailing list