This is an archive of the discontinued LLVM Phabricator instance.

[lldb][NFC] Remove FormatMap
ClosedPublic

Authored by teemperor on Jul 22 2020, 1:42 AM.
Tokens
"Pterodactyl" token, awarded by JDevlieghere.

Details

Summary

FormattersContainer.h has two containers: FormatMap and FormattersContainer itself.
FormatMap is essentially just a SetVector with a listener interface that is aspiring to be
thread-safe as most of its functions lock its member mutex.

FormattersContainer is for the most part just calling the matching functions of internal FormatMap instance
and essentially acts as a wrapper class with some minor formatter search functionality on top.
The only difference is that the FormattersContainer's public Get function is actually
searching formatters in the list of formatters (and for example doing regex-matching) while
FormatMap's Get function is just looking up a a format by the type matcher string.

This patch deletes FormatMap by just renaming it to FormattersContainer and
pulling in the two Get functions from the original FormattersContainer class.

The only other user of FormatMap was the NamedSummariesMap in the
FormatManager which I migrated by just making it also a FormattersContainer
and replaced the only call to the Get function (which now has new semantics)
with GetExact (which is FormattersContainer's function that has the semantics
of FormatMap's Get). As NamedSummariesMap only stores non-regex-based
formatters, both Get and GetExact would have worked, so this was mostly
to clarify that this is supposed to be NFC.

I also added the missing mutex lock in the GetCount function which was previously
missing in the FormatMap implementation. Technically not "NFC" but I anyway
had to change the function...

Diff Detail

Event Timeline

teemperor created this revision.Jul 22 2020, 1:42 AM
labath accepted this revision.Jul 22 2020, 1:48 AM

I do recall this being fairly messy, but I never took the time to figure out the reasons for it. Seems like a nice cleanup though.

lldb/include/lldb/DataFormatters/FormattersContainer.h
178

make_shared ?

This revision is now accepted and ready to land.Jul 22 2020, 1:48 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2020, 9:35 AM