[Lldb-commits] [PATCH] D134244: [NFCI] Clean up enum FormatCategoryItem.

Jorge Gorbe Moya via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Sep 19 17:03:26 PDT 2022


jgorbe created this revision.
jgorbe added reviewers: labath, rupprecht, jingham.
jgorbe added a project: LLDB.
Herald added a subscriber: JDevlieghere.
Herald added a project: All.
jgorbe requested review of this revision.



- Merge pairs like `eFormatCategoryItemSummary` and `eFormatCategoryItemRegexSummary` into a single value. See explanation below.

- Rename `eFormatCategoryItemValue` to `eFormatCategoryItemFormat`. This makes the enum match the names used elsewhere for formatter kinds (format, summary, filter, synth).

- Delete unused values `eFormatCategoryItemValidator` and `eFormatCategoryItemRegexValidator`.

This enum is only used to reuse some code in CommandObjectType.cpp.  For
example, instead of having separate implementations for `type summary
delete`, `type format delete`, and so on, there's a single generic
implementation that takes an enum value, and then the specific commands
derive from it and set the right flags for the specific kind of
formatter.

Even though the enum distinguishes between regular and regex matches for
every kind of formatter, this distinction is never used: enum values are
always specified in pairs like
`eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary`.

This causes some ugly code duplication in TypeCategory.cpp. In order to
handle every flag combination some code appears 8 times:

{format, summary, synth, filter} x {exact, regex}


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134244

Files:
  lldb/include/lldb/lldb-private-enumerations.h
  lldb/source/Commands/CommandObjectType.cpp
  lldb/source/DataFormatters/DataVisualization.cpp
  lldb/source/DataFormatters/TypeCategory.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134244.461418.patch
Type: text/x-patch
Size: 16680 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220920/ee653153/attachment.bin>


More information about the lldb-commits mailing list