Skip to content

Commit beadf7d

Browse files
committed
[lldb][NFC] Tablegenify type commands
llvm-svn: 366415
1 parent ce8df1f commit beadf7d

File tree

2 files changed

+101
-68
lines changed

2 files changed

+101
-68
lines changed

lldb/source/Commands/CommandObjectType.cpp

+22-68
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,8 @@ static bool WarnOnPotentialUnquotedUnsignedType(Args &command,
9696
}
9797

9898
static constexpr OptionDefinition g_type_summary_add_options[] = {
99-
// clang-format off
100-
{ LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Add this to the given category instead of the default one." },
101-
{ LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true, cascade through typedef chains." },
102-
{ LLDB_OPT_SET_ALL, false, "no-value", 'v', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't show the value, just show the summary, for this type." },
103-
{ LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects." },
104-
{ LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for references-to-type objects." },
105-
{ LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Type names are actually regular expressions." },
106-
{ LLDB_OPT_SET_1, true, "inline-children", 'c', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "If true, inline all child values into summary string." },
107-
{ LLDB_OPT_SET_1, false, "omit-names", 'O', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "If true, omit value names in the summary display." },
108-
{ LLDB_OPT_SET_2, true, "summary-string", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeSummaryString, "Summary string used to display text and object contents." },
109-
{ LLDB_OPT_SET_3, false, "python-script", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonScript, "Give a one-liner Python script as part of the command." },
110-
{ LLDB_OPT_SET_3, false, "python-function", 'F', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonFunction, "Give the name of a Python function to use for this type." },
111-
{ LLDB_OPT_SET_3, false, "input-python", 'P', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Input Python code to use for this type manually." },
112-
{ LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "expand", 'e', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Expand aggregate data types to show children on separate lines." },
113-
{ LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "hide-empty", 'h', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Do not expand aggregate data types with no children." },
114-
{ LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "name", 'n', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "A name for this summary string." }
115-
// clang-format on
99+
#define LLDB_OPTIONS_type_summary_add
100+
#include "CommandOptions.inc"
116101
};
117102

118103
class CommandObjectTypeSummaryAdd : public CommandObjectParsed,
@@ -298,15 +283,8 @@ static const char *g_synth_addreader_instructions =
298283
"class synthProvider:\n";
299284

300285
static constexpr OptionDefinition g_type_synth_add_options[] = {
301-
// clang-format off
302-
{ LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true, cascade through typedef chains." },
303-
{ LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects." },
304-
{ LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for references-to-type objects." },
305-
{ LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Add this to the given category instead of the default one." },
306-
{ LLDB_OPT_SET_2, false, "python-class", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonClass, "Use this Python class to produce synthetic children." },
307-
{ LLDB_OPT_SET_3, false, "input-python", 'P', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Type Python code to generate a class that provides synthetic children." },
308-
{ LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Type names are actually regular expressions." }
309-
// clang-format on
286+
#define LLDB_OPTIONS_type_synth_add
287+
#include "CommandOptions.inc"
310288
};
311289

312290
class CommandObjectTypeSynthAdd : public CommandObjectParsed,
@@ -526,14 +504,8 @@ class CommandObjectTypeSynthAdd : public CommandObjectParsed,
526504
// CommandObjectTypeFormatAdd
527505

528506
static constexpr OptionDefinition g_type_format_add_options[] = {
529-
// clang-format off
530-
{ LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Add this to the given category instead of the default one." },
531-
{ LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true, cascade through typedef chains." },
532-
{ LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects." },
533-
{ LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for references-to-type objects." },
534-
{ LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Type names are actually regular expressions." },
535-
{ LLDB_OPT_SET_2, false, "type", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Format variables as if they were of this type." }
536-
// clang-format on
507+
#define LLDB_OPTIONS_type_format_add
508+
#include "CommandOptions.inc"
537509
};
538510

539511
class CommandObjectTypeFormatAdd : public CommandObjectParsed {
@@ -749,11 +721,8 @@ pointers to floats. Nor will it change the default display for Afloat and Bfloa
749721
};
750722

751723
static constexpr OptionDefinition g_type_formatter_delete_options[] = {
752-
// clang-format off
753-
{ LLDB_OPT_SET_1, false, "all", 'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Delete from every category." },
754-
{ LLDB_OPT_SET_2, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Delete from given category." },
755-
{ LLDB_OPT_SET_3, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Delete from given language's category." }
756-
// clang-format on
724+
#define LLDB_OPTIONS_type_formatter_delete
725+
#include "CommandOptions.inc"
757726
};
758727

759728
class CommandObjectTypeFormatterDelete : public CommandObjectParsed {
@@ -891,9 +860,8 @@ class CommandObjectTypeFormatterDelete : public CommandObjectParsed {
891860
};
892861

893862
static constexpr OptionDefinition g_type_formatter_clear_options[] = {
894-
// clang-format off
895-
{ LLDB_OPT_SET_ALL, false, "all", 'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Clear every category." }
896-
// clang-format on
863+
#define LLDB_OPTIONS_type_formatter_clear
864+
#include "CommandOptions.inc"
897865
};
898866

899867
class CommandObjectTypeFormatterClear : public CommandObjectParsed {
@@ -1005,10 +973,8 @@ class CommandObjectTypeFormatClear : public CommandObjectTypeFormatterClear {
1005973

1006974

1007975
static constexpr OptionDefinition g_type_formatter_list_options[] = {
1008-
// clang-format off
1009-
{LLDB_OPT_SET_1, false, "category-regex", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Only show categories matching this filter."},
1010-
{LLDB_OPT_SET_2, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Only show the category for a specific language."}
1011-
// clang-format on
976+
#define LLDB_OPTIONS_type_formatter_list
977+
#include "CommandOptions.inc"
1012978
};
1013979

1014980
template <typename FormatterType>
@@ -1767,10 +1733,8 @@ class CommandObjectTypeSummaryList
17671733
// CommandObjectTypeCategoryDefine
17681734

17691735
static constexpr OptionDefinition g_type_category_define_options[] = {
1770-
// clang-format off
1771-
{ LLDB_OPT_SET_ALL, false, "enabled", 'e', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "If specified, this category will be created enabled." },
1772-
{ LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Specify the language that this category is supported for." }
1773-
// clang-format on
1736+
#define LLDB_OPTIONS_type_category_define
1737+
#include "CommandOptions.inc"
17741738
};
17751739

17761740
class CommandObjectTypeCategoryDefine : public CommandObjectParsed {
@@ -1872,9 +1836,8 @@ class CommandObjectTypeCategoryDefine : public CommandObjectParsed {
18721836
// CommandObjectTypeCategoryEnable
18731837

18741838
static constexpr OptionDefinition g_type_category_enable_options[] = {
1875-
// clang-format off
1876-
{ LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Enable the category for this language." },
1877-
// clang-format on
1839+
#define LLDB_OPTIONS_type_category_enable
1840+
#include "CommandOptions.inc"
18781841
};
18791842

18801843
class CommandObjectTypeCategoryEnable : public CommandObjectParsed {
@@ -2045,9 +2008,8 @@ class CommandObjectTypeCategoryDelete : public CommandObjectParsed {
20452008
// CommandObjectTypeCategoryDisable
20462009

20472010
OptionDefinition constexpr g_type_category_disable_options[] = {
2048-
// clang-format off
2049-
{ LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Enable the category for this language." }
2050-
// clang-format on
2011+
#define LLDB_OPTIONS_type_category_disable
2012+
#include "CommandOptions.inc"
20512013
};
20522014

20532015
class CommandObjectTypeCategoryDisable : public CommandObjectParsed {
@@ -2455,14 +2417,8 @@ bool CommandObjectTypeSynthAdd::AddSynth(ConstString type_name,
24552417
#endif // LLDB_DISABLE_PYTHON
24562418

24572419
static constexpr OptionDefinition g_type_filter_add_options[] = {
2458-
// clang-format off
2459-
{ LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true, cascade through typedef chains." },
2460-
{ LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects." },
2461-
{ LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for references-to-type objects." },
2462-
{ LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Add this to the given category instead of the default one." },
2463-
{ LLDB_OPT_SET_ALL, false, "child", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeExpressionPath, "Include this expression path in the synthetic view." },
2464-
{ LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Type names are actually regular expressions." }
2465-
// clang-format on
2420+
#define LLDB_OPTIONS_type_filter_add
2421+
#include "CommandOptions.inc"
24662422
};
24672423

24682424
class CommandObjectTypeFilterAdd : public CommandObjectParsed {
@@ -2708,10 +2664,8 @@ all children of my_foo as if no filter was defined:"
27082664

27092665
// "type lookup"
27102666
static constexpr OptionDefinition g_type_lookup_options[] = {
2711-
// clang-format off
2712-
{ LLDB_OPT_SET_ALL, false, "show-help", 'h', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display available help for types" },
2713-
{ LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Which language's types should the search scope be" }
2714-
// clang-format on
2667+
#define LLDB_OPTIONS_type_lookup
2668+
#include "CommandOptions.inc"
27152669
};
27162670

27172671
class CommandObjectTypeLookup : public CommandObjectRaw {

lldb/source/Commands/Options.td

+79
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,85 @@ let Command = "breakpoint list" in {
5252
"provided, which prime new targets.">;
5353
}
5454

55+
let Command = "type summary add" in {
56+
def type_summary_add_category : Option<"category", "w">, Arg<"Name">, Desc<"Add this to the given category instead of the default one.">;
57+
def type_summary_add_cascade : Option<"cascade", "C">, Arg<"Boolean">, Desc<"If true, cascade through typedef chains.">;
58+
def type_summary_add_no_value : Option<"no-value", "v">, Desc<"Don't show the value, just show the summary, for this type.">;
59+
def type_summary_add_skip_pointers : Option<"skip-pointers", "p">, Desc<"Don't use this format for pointers-to-type objects.">;
60+
def type_summary_add_skip_references : Option<"skip-references", "r">, Desc<"Don't use this format for references-to-type objects.">;
61+
def type_summary_add_regex : Option<"regex", "x">, Desc<"Type names are actually regular expressions.">;
62+
def type_summary_add_inline_children : Option<"inline-children", "c">, Group<1>, Required, Desc<"If true, inline all child values into summary string.">;
63+
def type_summary_add_omit_names : Option<"omit-names", "O">, Group<1>, Desc<"If true, omit value names in the summary display.">;
64+
def type_summary_add_summary_string : Option<"summary-string", "s">, Group<2>, Arg<"SummaryString">, Required, Desc<"Summary string used to display text and object contents.">;
65+
def type_summary_add_python_script : Option<"python-script", "o">, Group<3>, Arg<"PythonScript">, Desc<"Give a one-liner Python script as part of the command.">;
66+
def type_summary_add_python_function : Option<"python-function", "F">, Group<3>, Arg<"PythonFunction">, Desc<"Give the name of a Python function to use for this type.">;
67+
def type_summary_add_input_python : Option<"input-python", "P">, Group<3>, Desc<"Input Python code to use for this type manually.">;
68+
def type_summary_add_expand : Option<"expand", "e">, Groups<[2,3]>, Desc<"Expand aggregate data types to show children on separate lines.">;
69+
def type_summary_add_hide_empty : Option<"hide-empty", "h">, Groups<[2,3]>, Desc<"Do not expand aggregate data types with no children.">;
70+
def type_summary_add_name : Option<"name", "n">, Groups<[2,3]>, Arg<"Name">, Desc<"A name for this summary string.">;
71+
}
72+
73+
let Command = "type synth add" in {
74+
def type_synth_add_cascade : Option<"cascade", "C">, Arg<"Boolean">, Desc<"If true, cascade through typedef chains.">;
75+
def type_synth_add_skip_pointers : Option<"skip-pointers", "p">, Desc<"Don't use this format for pointers-to-type objects.">;
76+
def type_synth_add_skip_references : Option<"skip-references", "r">, Desc<"Don't use this format for references-to-type objects.">;
77+
def type_synth_add_category : Option<"category", "w">, Arg<"Name">, Desc<"Add this to the given category instead of the default one.">;
78+
def type_synth_add_python_class : Option<"python-class", "l">, Group<2>, Arg<"PythonClass">, Desc<"Use this Python class to produce synthetic children.">;
79+
def type_synth_add_input_python : Option<"input-python", "P">, Group<3>, Desc<"Type Python code to generate a class that provides synthetic children.">;
80+
def type_synth_add_regex : Option<"regex", "x">, Desc<"Type names are actually regular expressions.">;
81+
}
82+
83+
let Command = "type format add" in {
84+
def type_format_add_category : Option<"category", "w">, Arg<"Name">, Desc<"Add this to the given category instead of the default one.">;
85+
def type_format_add_cascade : Option<"cascade", "C">, Arg<"Boolean">, Desc<"If true, cascade through typedef chains.">;
86+
def type_format_add_skip_pointers : Option<"skip-pointers", "p">, Desc<"Don't use this format for pointers-to-type objects.">;
87+
def type_format_add_skip_references : Option<"skip-references", "r">, Desc<"Don't use this format for references-to-type objects.">;
88+
def type_format_add_regex : Option<"regex", "x">, Desc<"Type names are actually regular expressions.">;
89+
def type_format_add_type : Option<"type", "t">, Group<2>, Arg<"Name">, Desc<"Format variables as if they were of this type.">;
90+
}
91+
92+
let Command = "type formatter delete" in {
93+
def type_formatter_delete_all : Option<"all", "a">, Group<1>, Desc<"Delete from every category.">;
94+
def type_formatter_delete_category : Option<"category", "w">, Group<2>, Arg<"Name">, Desc<"Delete from given category.">;
95+
def type_formatter_delete_language : Option<"language", "l">, Group<3>, Arg<"Language">, Desc<"Delete from given language's category.">;
96+
}
97+
98+
let Command = "type formatter clear" in {
99+
def type_formatter_clear_all : Option<"all", "a">, Desc<"Clear every category.">;
100+
}
101+
102+
let Command = "type formatter list" in {
103+
def type_formatter_list_category_regex : Option<"category-regex", "w">, Group<1>, Arg<"Name">, Desc<"Only show categories matching this filter.">;
104+
def type_formatter_list_language : Option<"language", "l">, Group<2>, Arg<"Language">, Desc<"Only show the category for a specific language.">;
105+
}
106+
107+
let Command = "type category define" in {
108+
def type_category_define_enabled : Option<"enabled", "e">, Desc<"If specified, this category will be created enabled.">;
109+
def type_category_define_language : Option<"language", "l">, Arg<"Language">, Desc<"Specify the language that this category is supported for.">;
110+
}
111+
112+
let Command = "type category enable" in {
113+
def type_category_enable_language : Option<"language", "l">, Arg<"Language">, Desc<"Enable the category for this language.">;
114+
}
115+
116+
let Command = "type category disable" in {
117+
def type_category_disable_language : Option<"language", "l">, Arg<"Language">, Desc<"Enable the category for this language.">;
118+
}
119+
120+
let Command = "type filter add" in {
121+
def type_filter_add_cascade : Option<"cascade", "C">, Arg<"Boolean">, Desc<"If true, cascade through typedef chains.">;
122+
def type_filter_add_skip_pointers : Option<"skip-pointers", "p">, Desc<"Don't use this format for pointers-to-type objects.">;
123+
def type_filter_add_skip_references : Option<"skip-references", "r">, Desc<"Don't use this format for references-to-type objects.">;
124+
def type_filter_add_category : Option<"category", "w">, Arg<"Name">, Desc<"Add this to the given category instead of the default one.">;
125+
def type_filter_add_child : Option<"child", "c">, Arg<"ExpressionPath">, Desc<"Include this expression path in the synthetic view.">;
126+
def type_filter_add_regex : Option<"regex", "x">, Desc<"Type names are actually regular expressions.">;
127+
}
128+
129+
let Command = "type lookup" in {
130+
def type_lookup_show_help : Option<"show-help", "h">, Desc<"Display available help for types">;
131+
def type_lookup_language : Option<"language", "l">, Arg<"Language">, Desc<"Which language's types should the search scope be">;
132+
}
133+
55134
let Command = "watchpoint list" in {
56135
def watchpoint_list_brief : Option<"brief", "b">, Group<1>, Desc<"Give a "
57136
"brief description of the watchpoint (no location info).">;

0 commit comments

Comments
 (0)