This is an archive of the discontinued LLVM Phabricator instance.

Add formatter for libc++ std::unique_ptr
ClosedPublic

Authored by shafik on Mar 19 2020, 9:17 PM.

Details

Summary

This adds a formatter for libc++ std::unique_ptr. We currently already have formatters for std::shared_ptr and std::weak_ptr.

I also refactored GetValueOfCompressedPair(...) out of LibCxxList.cpp since I need the same functionality and it made sense to share it.

Diff Detail

Event Timeline

shafik created this revision.Mar 19 2020, 9:17 PM
vsk added a comment.Mar 20 2020, 8:02 AM

Awesome :)

lldb/include/lldb/DataFormatters/FormattersHelpers.h
59

Mind adding ‘libcxx’ somewhere in the function name, to avoid confusion?

lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
618

Does this need to match for rvalue refs, like ‘unique_ptr<blah> &&’?

730

Can we share the regex definition?

shafik updated this revision to Diff 251707.Mar 20 2020, 11:03 AM
shafik marked 4 inline comments as done.

Addressing comments on naming and not duplicating the regex

lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
618

I tried this out and apparently not.

vsk accepted this revision.Mar 20 2020, 11:46 AM

LGTM with some added test coverage. Jim?

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp
10

Could you add test coverage for '&' and '&&', like

const std::unique_ptr<std::string> &up_str_ref = up_str;
std::unique_ptr<int> &&up_int_rvref = std::move(up_int);
This revision is now accepted and ready to land.Mar 20 2020, 11:46 AM
shafik updated this revision to Diff 251783.Mar 20 2020, 3:04 PM
shafik marked an inline comment as done.

Adding addition tests for references

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2020, 12:01 PM