[all-commits] [llvm/llvm-project] dce688: [NFCI] Clean up enum FormatCategoryItem.

Jorge Gorbe Moya via All-commits all-commits at lists.llvm.org
Tue Sep 20 10:43:53 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dce68873360097be77ff8b3ce68b6eedc612fbef
      https://github.com/llvm/llvm-project/commit/dce68873360097be77ff8b3ce68b6eedc612fbef
  Author: Jorge Gorbe Moya <jgorbe at google.com>
  Date:   2022-09-20 (Tue, 20 Sep 2022)

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

  Log Message:
  -----------
  [NFCI] Clean up enum FormatCategoryItem.

- 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}

Differential Revision: https://reviews.llvm.org/D134244




More information about the All-commits mailing list