jingham updated this revision to Diff 516590.
jingham added a comment.
Adopt suggestions from Alex.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148282/new/
https://reviews.llvm.org/D148282
Files:
lldb/source/Commands/CommandObjectType.cpp
Index: lldb/source/Commands/CommandObjectType.cpp
===================================================================
--- lldb/source/Commands/CommandObjectType.cpp
+++ lldb/source/Commands/CommandObjectType.cpp
@@ -39,9 +39,6 @@
#include <functional>
#include <memory>
-#define CHECK_FORMATTER_KIND_MASK(VAL) \
- ((m_formatter_kind_mask & (VAL)) == (VAL))
-
using namespace lldb;
using namespace lldb_private;
@@ -100,6 +97,22 @@
return false;
}
+const char *FormatCategoryToString(FormatCategoryItem item, bool long_name) {
+ switch (item) {
+ case eFormatCategoryItemSummary:
+ return "summary";
+ case eFormatCategoryItemFilter:
+ return "filter";
+ case eFormatCategoryItemSynth:
+ if (long_name)
+ return "synthetic child provider";
+ return "synthetic";
+ case eFormatCategoryItemFormat:
+ return "format";
+ }
+ llvm_unreachable("Fully covered switch above!");
+};
+
#define LLDB_OPTIONS_type_summary_add
#include "CommandOptions.inc"
@@ -754,16 +767,25 @@
};
CommandOptions m_options;
- uint32_t m_formatter_kind_mask;
+ FormatCategoryItem m_formatter_kind;
Options *GetOptions() override { return &m_options; }
+
+ static constexpr const char *g_short_help_template =
+ "Delete an existing %s for a type.";
+
+ static constexpr const char *g_long_help_template =
+ "Delete an existing %s for a type. Unless you specify a "
+ "specific category or all categories, only the "
+ "'default' category is searched. The names must be exactly as "
+ "shown in the 'type %s list' output";
public:
CommandObjectTypeFormatterDelete(CommandInterpreter &interpreter,
- uint32_t formatter_kind_mask,
- const char *name, const char *help)
- : CommandObjectParsed(interpreter, name, help, nullptr),
- m_formatter_kind_mask(formatter_kind_mask) {
+ FormatCategoryItem formatter_kind)
+ : CommandObjectParsed(interpreter,
+ FormatCategoryToString(formatter_kind, false)),
+ m_formatter_kind(formatter_kind) {
CommandArgumentEntry type_arg;
CommandArgumentData type_style_arg;
@@ -773,6 +795,19 @@
type_arg.push_back(type_style_arg);
m_arguments.push_back(type_arg);
+
+ const char *kind = FormatCategoryToString(formatter_kind, true);
+ const char *short_kind = FormatCategoryToString(formatter_kind, false);
+
+ StreamString s;
+ s.Printf(g_short_help_template, kind);
+ SetHelp(s.GetData());
+ s.Clear();
+ s.Printf(g_long_help_template, kind, short_kind);
+ SetHelpLong(s.GetData());
+ s.Clear();
+ s.Printf("type %s delete", short_kind);
+ SetCommandName(s.GetData());
}
~CommandObjectTypeFormatterDelete() override = default;
@@ -785,7 +820,7 @@
DataVisualization::Categories::ForEach(
[this, &request](const lldb::TypeCategoryImplSP &category_sp) {
- category_sp->AutoComplete(request, m_formatter_kind_mask);
+ category_sp->AutoComplete(request, m_formatter_kind);
return true;
});
}
@@ -812,7 +847,7 @@
if (m_options.m_delete_all) {
DataVisualization::Categories::ForEach(
[this, typeCS](const lldb::TypeCategoryImplSP &category_sp) -> bool {
- category_sp->Delete(typeCS, m_formatter_kind_mask);
+ category_sp->Delete(typeCS, m_formatter_kind);
return true;
});
result.SetStatus(eReturnStatusSuccessFinishNoResult);
@@ -827,14 +862,14 @@
DataVisualization::Categories::GetCategory(m_options.m_language,
category);
if (category)
- delete_category = category->Delete(typeCS, m_formatter_kind_mask);
+ delete_category = category->Delete(typeCS, m_formatter_kind);
extra_deletion = FormatterSpecificDeletion(typeCS);
} else {
lldb::TypeCategoryImplSP category;
DataVisualization::Categories::GetCategory(
ConstString(m_options.m_category.c_str()), category);
if (category)
- delete_category = category->Delete(typeCS, m_formatter_kind_mask);
+ delete_category = category->Delete(typeCS, m_formatter_kind);
extra_deletion = FormatterSpecificDeletion(typeCS);
}
@@ -888,16 +923,16 @@
};
CommandOptions m_options;
- uint32_t m_formatter_kind_mask;
+ FormatCategoryItem m_formatter_kind;
Options *GetOptions() override { return &m_options; }
public:
CommandObjectTypeFormatterClear(CommandInterpreter &interpreter,
- uint32_t formatter_kind_mask,
+ FormatCategoryItem formatter_kind,
const char *name, const char *help)
: CommandObjectParsed(interpreter, name, help, nullptr),
- m_formatter_kind_mask(formatter_kind_mask) {
+ m_formatter_kind(formatter_kind) {
CommandArgumentData category_arg{eArgTypeName, eArgRepeatOptional};
m_arguments.push_back({category_arg});
}
@@ -911,7 +946,7 @@
if (m_options.m_delete_all) {
DataVisualization::Categories::ForEach(
[this](const TypeCategoryImplSP &category_sp) -> bool {
- category_sp->Clear(m_formatter_kind_mask);
+ category_sp->Clear(m_formatter_kind);
return true;
});
} else {
@@ -924,7 +959,7 @@
DataVisualization::Categories::GetCategory(ConstString(nullptr),
category);
}
- category->Clear(m_formatter_kind_mask);
+ category->Clear(m_formatter_kind);
}
FormatterSpecificDeletion();
@@ -940,8 +975,7 @@
public:
CommandObjectTypeFormatDelete(CommandInterpreter &interpreter)
: CommandObjectTypeFormatterDelete(
- interpreter, eFormatCategoryItemFormat, "type format delete",
- "Delete an existing formatting style for a type.") {}
+ interpreter, eFormatCategoryItemFormat) {}
~CommandObjectTypeFormatDelete() override = default;
};
@@ -1609,8 +1643,7 @@
public:
CommandObjectTypeSummaryDelete(CommandInterpreter &interpreter)
: CommandObjectTypeFormatterDelete(
- interpreter, eFormatCategoryItemSummary, "type summary delete",
- "Delete an existing summary for a type.") {}
+ interpreter, eFormatCategoryItemSummary) {}
~CommandObjectTypeSummaryDelete() override = default;
@@ -2159,8 +2192,7 @@
public:
CommandObjectTypeFilterDelete(CommandInterpreter &interpreter)
: CommandObjectTypeFormatterDelete(
- interpreter, eFormatCategoryItemFilter, "type filter delete",
- "Delete an existing filter for a type.") {}
+ interpreter, eFormatCategoryItemFilter) {}
~CommandObjectTypeFilterDelete() override = default;
};
@@ -2173,8 +2205,7 @@
public:
CommandObjectTypeSynthDelete(CommandInterpreter &interpreter)
: CommandObjectTypeFormatterDelete(
- interpreter, eFormatCategoryItemSynth, "type synthetic delete",
- "Delete an existing synthetic provider for a type.") {}
+ interpreter, eFormatCategoryItemSynth) {}
~CommandObjectTypeSynthDelete() override = default;
};
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits