This is an archive of the discontinued LLVM Phabricator instance.

Move FormattersMatchCandidate flags to a struct.
ClosedPublic

Authored by jgorbe on Aug 8 2022, 6:09 PM.

Details

Summary

Move FormattersMatchCandidate flags to a struct.

This removes some error-prone repetition in
FormatManager::GetPossibleMatches, where the same three boolean flags
are passed in a row multiple times as arguments to recursive calls to
GetPossibleMatches.

Instead of:

// same flags, but with did_strip_typedef set to true.
GetPossibleMatches(..., did_strip_ptr, did_strip_ref, true);

we can now say

GetPossibleMatches(..., current_flags.WithStrippedTypedef());

which hopefully makes the intent clearer, and more readable in case we
add another flag.

Diff Detail

Event Timeline

jgorbe created this revision.Aug 8 2022, 6:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2022, 6:09 PM
jgorbe requested review of this revision.Aug 8 2022, 6:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2022, 6:09 PM
DavidSpickett accepted this revision.Aug 9 2022, 1:12 AM
DavidSpickett added a subscriber: DavidSpickett.

LGTM, a nice improvement.

This revision is now accepted and ready to land.Aug 9 2022, 1:12 AM
labath accepted this revision.Aug 9 2022, 6:44 AM
labath added a subscriber: labath.
labath added inline comments.
lldb/include/lldb/DataFormatters/FormatClasses.h
50

We don't generally use the m_ prefix on structs. This struct is a bit of an edge case, as it has non-trivial member functions -- so one could consider making it a class (members private and public accessors) -- but if you don't want to do that (which is fine by me), then I think it'd be better to remove the prefixes.

This revision was landed with ongoing or failed builds.Aug 9 2022, 10:49 AM
This revision was automatically updated to reflect the committed changes.