Page MenuHomePhabricator

[llvm][utils] Support dereferencing llvm::Optional lldb formatter

Authored by kastiglione on Feb 25 2021, 8:22 PM.



Add deref support to llvm::Optional in

This creates a synthetic provider that adds dereference support, but otherwise proxies all access to the underlying value.

With this change, an optional value can be displayed by running v *someOptional, and its contents can be accessed with the arrow operator->, for example v someOpt->HasThing. This matches expressions usable from expression evaluation.

See also D97165 and D97524.

Diff Detail

Event Timeline

kastiglione requested review of this revision.Feb 25 2021, 8:22 PM
kastiglione created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 25 2021, 8:22 PM

Awesome. Can't wait to use this.


Are the other changes in this patch just general bug-fixes or unrelated cleanup? Things like the new import or the dict rename to internal_dict ?

@teemperor I switched dict to internal_dict because more code uses internal_dict, and because variables named dict shadow the dict constructor. The dict constructor isn't used, but I think it's better to avoid shadowing it.


@teemperor this is why the import lldb is needed

fix docstring

teemperor accepted this revision.Feb 26 2021, 7:40 AM

LGTM, but please land the renames for dict in their own NFC commit (no need to open a review for that obviously)


Thanks, missed that use

This revision is now accepted and ready to land.Feb 26 2021, 7:40 AM

back out dict renames

This revision was landed with ongoing or failed builds.Feb 26 2021, 7:43 AM
This revision was automatically updated to reflect the committed changes.
kastiglione added inline comments.Feb 26 2021, 8:13 AM

oops this was an innocuous off by one (it still worked), I removed the +1 in a01a406bba8ac624a876f8d5720e1d4949a5b0fa