Nowhere in lldb do we call this with a null pointer.
If we did, the first line of the function would fault anyway.
Reviewed By: JDevlieghere
Differential Revision: https://reviews.llvm.org/D125218
const OptionDefinition &option_def,
uint32_t output_max_columns);
- void GenerateOptionUsage(Stream &strm, CommandObject *cmd,
+ void GenerateOptionUsage(Stream &strm, CommandObject &cmd,
uint32_t screen_width);
bool SupportsLongOption(const char *long_option);
"\"disassemble\" arguments are specified as options.\n");
const int terminal_width =
GetCommandInterpreter().GetDebugger().GetTerminalWidth();
- GetOptions()->GenerateOptionUsage(result.GetErrorStream(), this,
+ GetOptions()->GenerateOptionUsage(result.GetErrorStream(), *this,
terminal_width);
return false;
}
"too many arguments; expected frame-index, saw '%s'.\n",
command[0].c_str());
m_options.GenerateOptionUsage(
- result.GetErrorStream(), this,
+ result.GetErrorStream(), *this,
GetCommandInterpreter().GetDebugger().GetTerminalWidth());
return false;
}
default:
m_options.GenerateOptionUsage(
- result.GetErrorStream(), this,
+ result.GetErrorStream(), *this,
GetCommandInterpreter().GetDebugger().GetTerminalWidth());
syntax_error = true;
break;
} else {
// No error string, output the usage information into result
options->GenerateOptionUsage(
- result.GetErrorStream(), this,
+ result.GetErrorStream(), *this,
GetCommandInterpreter().GetDebugger().GetTerminalWidth());
}
}
if (!found_word && search_options && GetOptions() != nullptr) {
StreamString usage_help;
GetOptions()->GenerateOptionUsage(
- usage_help, this,
+ usage_help, *this,
GetCommandInterpreter().GetDebugger().GetTerminalWidth());
if (!usage_help.Empty()) {
llvm::StringRef usage_text = usage_help.GetString();
Options *options = GetOptions();
if (options != nullptr) {
options->GenerateOptionUsage(
- output_strm, this,
+ output_strm, *this,
GetCommandInterpreter().GetDebugger().GetTerminalWidth());
}
llvm::StringRef long_help = GetHelpLong();
return true;
}
-void Options::GenerateOptionUsage(Stream &strm, CommandObject *cmd,
+void Options::GenerateOptionUsage(Stream &strm, CommandObject &cmd,
uint32_t screen_width) {
- const bool only_print_args = cmd->IsDashDashCommand();
+ const bool only_print_args = cmd.IsDashDashCommand();
auto opt_defs = GetDefinitions();
const uint32_t save_indent_level = strm.GetIndentLevel();
- llvm::StringRef name;
-
+ llvm::StringRef name = cmd.GetCommandName();
StreamString arguments_str;
-
- if (cmd) {
- name = cmd->GetCommandName();
- cmd->GetFormattedCommandArguments(arguments_str);
- } else
- name = "";
+ cmd.GetFormattedCommandArguments(arguments_str);
const uint32_t num_options = NumCommandOptions();
if (num_options == 0)
// Different option sets may require different args.
StreamString args_str;
- if (cmd)
- cmd->GetFormattedCommandArguments(args_str, opt_set_mask);
+ cmd.GetFormattedCommandArguments(args_str, opt_set_mask);
// First go through and print all options that take no arguments as a
// single string. If a command has "-a" "-b" and "-c", this will show up
}
if (args_str.GetSize() > 0) {
- if (cmd->WantsRawCommandString() && !only_print_args)
+ if (cmd.WantsRawCommandString() && !only_print_args)
strm.Printf(" --");
strm << " " << args_str.GetString();
}
}
- if (cmd && (only_print_args || cmd->WantsRawCommandString()) &&
+ if ((only_print_args || cmd.WantsRawCommandString()) &&
arguments_str.GetSize() > 0) {
if (!only_print_args)
strm.PutChar('\n');