[PATCH] LLDB formatter for llvm::Optional

Enrico Granata egranata at apple.com
Thu Feb 19 12:29:47 PST 2015


Instead of str(), one could use .GetSummary() on the casted SBValue. And if that returns None, fallback to GetValue(). IIRC, str(SBValue) does a little more than necessary.

Sent from my iPhone

> On Feb 19, 2015, at 12:02 PM, Eric Christopher <echristo at gmail.com> wrote:
> 
> *shrug* If Enrico doesn't have any further comments I'd just commit. :)
> 
> -eric
> 
>> On Thu Feb 19 2015 at 12:01:11 PM Justin Bogner <mail at justinbogner.com> wrote:
>> ping
>> 
>> Justin Bogner <mail at justinbogner.com> writes:
>> > Enrico Granata <egranata at apple.com> writes:
>> >> Without much awareness of the implementation details of
>> >> llvm::Optional, this storage.Cast worries me a little bit
>> >> SBValue::Cast() is a sharp and dangerous tool It is not the moral
>> >> equivalent of a language cast; it pretty simply replaces the type of
>> >> the data leaving it exactly intact - so your mileage may vary with it
>> >
>> > I believe this is exactly the correct behaviour in this
>> > case. llvm::Optional<T> basically creates a char[] of appropriate size
>> > for storage of the T. We really do just want to treat this as the
>> > particular type.
>> >
>> >> It looks like here it would work, because this is a correctly-sized buffer and
>> >> you really just want to swap the SBType, but I would test with more than int
>> >> to make sure
>> >
>> > I've tried this with a few llvm types, it works well :)
>> >
>> > Is the usage of str() appropriate?
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150219/8167c2f1/attachment.html>


More information about the llvm-commits mailing list