mirror of
https://github.com/intel/llvm.git
synced 2026-01-13 11:02:04 +08:00
[lldb][NFC] Remove ArgEntry::ref member
The StringRef should always be identical to the C string, so we might as well just create the StringRef from the C-string. This might be slightly slower until we implement the storage of ArgEntry with a string instead of a std::unique_ptr<char[]>. Until then we have to do the additional strlen on the C string to construct the StringRef. llvm-svn: 371842
This commit is contained in:
@@ -43,7 +43,7 @@ public:
|
||||
ArgEntry() = default;
|
||||
ArgEntry(llvm::StringRef str, char quote);
|
||||
|
||||
llvm::StringRef ref;
|
||||
llvm::StringRef ref() const { return c_str(); }
|
||||
const char *c_str() const { return ptr.get(); }
|
||||
|
||||
/// Returns true if this argument was quoted in any way.
|
||||
|
||||
@@ -122,7 +122,7 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target,
|
||||
for (size_t i = 0; i < old_args.size(); ++i) {
|
||||
bool is_range = false;
|
||||
|
||||
current_arg = old_args[i].ref;
|
||||
current_arg = old_args[i].ref();
|
||||
if (!allow_locations && current_arg.contains('.')) {
|
||||
result.AppendErrorWithFormat(
|
||||
"Breakpoint locations not allowed, saw location: %s.",
|
||||
@@ -146,16 +146,16 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target,
|
||||
} else
|
||||
names_found.insert(current_arg);
|
||||
} else if ((i + 2 < old_args.size()) &&
|
||||
BreakpointID::IsRangeIdentifier(old_args[i + 1].ref) &&
|
||||
BreakpointID::IsRangeIdentifier(old_args[i + 1].ref()) &&
|
||||
BreakpointID::IsValidIDExpression(current_arg) &&
|
||||
BreakpointID::IsValidIDExpression(old_args[i + 2].ref)) {
|
||||
BreakpointID::IsValidIDExpression(old_args[i + 2].ref())) {
|
||||
range_from = current_arg;
|
||||
range_to = old_args[i + 2].ref;
|
||||
range_to = old_args[i + 2].ref();
|
||||
is_range = true;
|
||||
i = i + 2;
|
||||
} else {
|
||||
// See if user has specified id.*
|
||||
llvm::StringRef tmp_str = old_args[i].ref;
|
||||
llvm::StringRef tmp_str = old_args[i].ref();
|
||||
size_t pos = tmp_str.find('.');
|
||||
if (pos != llvm::StringRef::npos) {
|
||||
llvm::StringRef bp_id_str = tmp_str.substr(0, pos);
|
||||
|
||||
@@ -44,7 +44,7 @@ bool CommandObjectApropos::DoExecute(Args &args, CommandReturnObject &result) {
|
||||
const size_t argc = args.GetArgumentCount();
|
||||
|
||||
if (argc == 1) {
|
||||
auto search_word = args[0].ref;
|
||||
auto search_word = args[0].ref();
|
||||
if (!search_word.empty()) {
|
||||
// The bulk of the work must be done inside the Command Interpreter,
|
||||
// since the command dictionary is private.
|
||||
@@ -79,7 +79,7 @@ bool CommandObjectApropos::DoExecute(Args &args, CommandReturnObject &result) {
|
||||
const bool dump_qualified_name = true;
|
||||
result.AppendMessageWithFormatv(
|
||||
"\nThe following settings variables may relate to '{0}': \n\n",
|
||||
args[0].ref);
|
||||
args[0].ref());
|
||||
for (size_t i = 0; i < num_properties; ++i)
|
||||
properties[i]->DumpDescription(
|
||||
m_interpreter, result.GetOutputStream(), 0, dump_qualified_name);
|
||||
|
||||
@@ -1707,7 +1707,7 @@ protected:
|
||||
// Make a pass through first to see that all the names are legal.
|
||||
for (auto &entry : command.entries()) {
|
||||
Status error;
|
||||
if (!BreakpointID::StringIsBreakpointName(entry.ref, error))
|
||||
if (!BreakpointID::StringIsBreakpointName(entry.ref(), error))
|
||||
{
|
||||
result.AppendErrorWithFormat("Invalid breakpoint name: %s - %s",
|
||||
entry.c_str(), error.AsCString());
|
||||
|
||||
@@ -283,7 +283,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
FileSpec cmd_file(command[0].ref);
|
||||
FileSpec cmd_file(command[0].ref());
|
||||
FileSystem::Instance().Resolve(cmd_file);
|
||||
ExecutionContext *exe_ctx = nullptr; // Just use the default context.
|
||||
|
||||
@@ -546,7 +546,7 @@ protected:
|
||||
|
||||
// Get the alias command.
|
||||
|
||||
auto alias_command = args[0].ref;
|
||||
auto alias_command = args[0].ref();
|
||||
if (alias_command.startswith("-")) {
|
||||
result.AppendError("aliases starting with a dash are not supported");
|
||||
if (alias_command == "--help" || alias_command == "--long-help") {
|
||||
@@ -653,8 +653,8 @@ protected:
|
||||
}
|
||||
|
||||
// Save these in std::strings since we're going to shift them off.
|
||||
const std::string alias_command(args[0].ref);
|
||||
const std::string actual_command(args[1].ref);
|
||||
const std::string alias_command(args[0].ref());
|
||||
const std::string actual_command(args[1].ref());
|
||||
|
||||
args.Shift(); // Shift the alias command word off the argument vector.
|
||||
args.Shift(); // Shift the old command word off the argument vector.
|
||||
@@ -686,7 +686,7 @@ protected:
|
||||
OptionArgVectorSP(new OptionArgVector);
|
||||
|
||||
while (cmd_obj->IsMultiwordObject() && !args.empty()) {
|
||||
auto sub_command = args[0].ref;
|
||||
auto sub_command = args[0].ref();
|
||||
assert(!sub_command.empty());
|
||||
subcommand_obj_sp = cmd_obj->GetSubcommandSP(sub_command);
|
||||
if (!subcommand_obj_sp) {
|
||||
@@ -780,7 +780,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
auto command_name = args[0].ref;
|
||||
auto command_name = args[0].ref();
|
||||
cmd_obj = m_interpreter.GetCommandObject(command_name);
|
||||
if (!cmd_obj) {
|
||||
result.AppendErrorWithFormat(
|
||||
@@ -862,7 +862,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
auto command_name = args[0].ref;
|
||||
auto command_name = args[0].ref();
|
||||
if (!m_interpreter.CommandExists(command_name)) {
|
||||
StreamString error_msg_stream;
|
||||
const bool generate_upropos = true;
|
||||
@@ -988,7 +988,7 @@ protected:
|
||||
}
|
||||
|
||||
Status error;
|
||||
auto name = command[0].ref;
|
||||
auto name = command[0].ref();
|
||||
m_regex_cmd_up = std::make_unique<CommandObjectRegexCommand>(
|
||||
m_interpreter, name, m_options.GetHelp(), m_options.GetSyntax(), 10, 0,
|
||||
true);
|
||||
@@ -1013,7 +1013,7 @@ protected:
|
||||
} else {
|
||||
for (auto &entry : command.entries().drop_front()) {
|
||||
bool check_only = false;
|
||||
error = AppendRegexSubstitution(entry.ref, check_only);
|
||||
error = AppendRegexSubstitution(entry.ref(), check_only);
|
||||
if (error.Fail())
|
||||
break;
|
||||
}
|
||||
@@ -1656,7 +1656,7 @@ protected:
|
||||
}
|
||||
|
||||
// Store the options in case we get multi-line input
|
||||
m_cmd_name = command[0].ref;
|
||||
m_cmd_name = command[0].ref();
|
||||
m_short_help.assign(m_options.m_short_help);
|
||||
m_synchronicity = m_options.m_synchronicity;
|
||||
|
||||
@@ -1798,7 +1798,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
auto cmd_name = command[0].ref;
|
||||
auto cmd_name = command[0].ref();
|
||||
|
||||
if (cmd_name.empty() || !m_interpreter.HasUserCommands() ||
|
||||
!m_interpreter.UserCommandExists(cmd_name)) {
|
||||
|
||||
@@ -358,7 +358,7 @@ protected:
|
||||
}
|
||||
|
||||
if (command.GetArgumentCount() == 1) {
|
||||
if (command[0].ref.getAsInteger(0, frame_idx)) {
|
||||
if (command[0].ref().getAsInteger(0, frame_idx)) {
|
||||
result.AppendErrorWithFormat("invalid frame index argument '%s'.",
|
||||
command[0].c_str());
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
@@ -527,7 +527,7 @@ protected:
|
||||
for (auto &entry : command) {
|
||||
if (m_option_variable.use_regex) {
|
||||
const size_t regex_start_index = regex_var_list.GetSize();
|
||||
llvm::StringRef name_str = entry.ref;
|
||||
llvm::StringRef name_str = entry.ref();
|
||||
RegularExpression regex(name_str);
|
||||
if (regex.IsValid()) {
|
||||
size_t num_matches = 0;
|
||||
@@ -586,7 +586,7 @@ protected:
|
||||
StackFrame::eExpressionPathOptionsInspectAnonymousUnions;
|
||||
lldb::VariableSP var_sp;
|
||||
valobj_sp = frame->GetValueForVariableExpressionPath(
|
||||
entry.ref, m_varobj_options.use_dynamic, expr_path_options,
|
||||
entry.ref(), m_varobj_options.use_dynamic, expr_path_options,
|
||||
var_sp, error);
|
||||
if (valobj_sp) {
|
||||
std::string scope_string;
|
||||
|
||||
@@ -96,7 +96,7 @@ bool CommandObjectHelp::DoExecute(Args &command, CommandReturnObject &result) {
|
||||
// Get command object for the first command argument. Only search built-in
|
||||
// command dictionary.
|
||||
StringList matches;
|
||||
auto command_name = command[0].ref;
|
||||
auto command_name = command[0].ref();
|
||||
cmd_obj = m_interpreter.GetCommandObject(command_name, &matches);
|
||||
|
||||
if (cmd_obj != nullptr) {
|
||||
@@ -107,7 +107,7 @@ bool CommandObjectHelp::DoExecute(Args &command, CommandReturnObject &result) {
|
||||
// object that corresponds to the help command entered.
|
||||
std::string sub_command;
|
||||
for (auto &entry : command.entries().drop_front()) {
|
||||
sub_command = entry.ref;
|
||||
sub_command = entry.ref();
|
||||
matches.Clear();
|
||||
if (sub_cmd_obj->IsAlias())
|
||||
sub_cmd_obj =
|
||||
@@ -208,7 +208,7 @@ void CommandObjectHelp::HandleCompletion(CompletionRequest &request) {
|
||||
return;
|
||||
}
|
||||
CommandObject *cmd_obj =
|
||||
m_interpreter.GetCommandObject(request.GetParsedLine()[0].ref);
|
||||
m_interpreter.GetCommandObject(request.GetParsedLine()[0].ref());
|
||||
|
||||
// The command that they are getting help on might be ambiguous, in which
|
||||
// case we should complete that, otherwise complete with the command the
|
||||
|
||||
@@ -145,7 +145,7 @@ protected:
|
||||
}
|
||||
|
||||
// Store into a std::string since we're about to shift the channel off.
|
||||
const std::string channel = args[0].ref;
|
||||
const std::string channel = args[0].ref();
|
||||
args.Shift(); // Shift off the channel
|
||||
char log_file[PATH_MAX];
|
||||
if (m_options.log_file)
|
||||
@@ -212,7 +212,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string channel = args[0].ref;
|
||||
const std::string channel = args[0].ref();
|
||||
args.Shift(); // Shift off the channel
|
||||
if (channel == "all") {
|
||||
Log::DisableAllLogChannels();
|
||||
@@ -265,7 +265,7 @@ protected:
|
||||
bool success = true;
|
||||
for (const auto &entry : args.entries())
|
||||
success =
|
||||
success && Log::ListChannelCategories(entry.ref, output_stream);
|
||||
success && Log::ListChannelCategories(entry.ref(), output_stream);
|
||||
if (success)
|
||||
result.SetStatus(eReturnStatusSuccessFinishResult);
|
||||
}
|
||||
@@ -291,7 +291,7 @@ protected:
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
|
||||
if (args.GetArgumentCount() == 1) {
|
||||
auto sub_command = args[0].ref;
|
||||
auto sub_command = args[0].ref();
|
||||
|
||||
if (sub_command.equals_lower("enable")) {
|
||||
Timer::SetDisplayDepth(UINT32_MAX);
|
||||
@@ -308,8 +308,8 @@ protected:
|
||||
result.SetStatus(eReturnStatusSuccessFinishResult);
|
||||
}
|
||||
} else if (args.GetArgumentCount() == 2) {
|
||||
auto sub_command = args[0].ref;
|
||||
auto param = args[1].ref;
|
||||
auto sub_command = args[0].ref();
|
||||
auto param = args[1].ref();
|
||||
|
||||
if (sub_command.equals_lower("enable")) {
|
||||
uint32_t depth;
|
||||
|
||||
@@ -593,7 +593,7 @@ protected:
|
||||
}
|
||||
|
||||
if (argc > 0)
|
||||
addr = OptionArgParser::ToAddress(&m_exe_ctx, command[0].ref,
|
||||
addr = OptionArgParser::ToAddress(&m_exe_ctx, command[0].ref(),
|
||||
LLDB_INVALID_ADDRESS, &error);
|
||||
|
||||
if (addr == LLDB_INVALID_ADDRESS) {
|
||||
@@ -605,7 +605,7 @@ protected:
|
||||
|
||||
if (argc == 2) {
|
||||
lldb::addr_t end_addr = OptionArgParser::ToAddress(
|
||||
&m_exe_ctx, command[1].ref, LLDB_INVALID_ADDRESS, nullptr);
|
||||
&m_exe_ctx, command[1].ref(), LLDB_INVALID_ADDRESS, nullptr);
|
||||
if (end_addr == LLDB_INVALID_ADDRESS) {
|
||||
result.AppendError("invalid end address expression.");
|
||||
result.AppendError(error.AsCString());
|
||||
@@ -1034,13 +1034,13 @@ protected:
|
||||
|
||||
Status error;
|
||||
lldb::addr_t low_addr = OptionArgParser::ToAddress(
|
||||
&m_exe_ctx, command[0].ref, LLDB_INVALID_ADDRESS, &error);
|
||||
&m_exe_ctx, command[0].ref(), LLDB_INVALID_ADDRESS, &error);
|
||||
if (low_addr == LLDB_INVALID_ADDRESS || error.Fail()) {
|
||||
result.AppendError("invalid low address");
|
||||
return false;
|
||||
}
|
||||
lldb::addr_t high_addr = OptionArgParser::ToAddress(
|
||||
&m_exe_ctx, command[1].ref, LLDB_INVALID_ADDRESS, &error);
|
||||
&m_exe_ctx, command[1].ref(), LLDB_INVALID_ADDRESS, &error);
|
||||
if (high_addr == LLDB_INVALID_ADDRESS || error.Fail()) {
|
||||
result.AppendError("invalid high address");
|
||||
return false;
|
||||
@@ -1339,7 +1339,7 @@ protected:
|
||||
|
||||
Status error;
|
||||
lldb::addr_t addr = OptionArgParser::ToAddress(
|
||||
&m_exe_ctx, command[0].ref, LLDB_INVALID_ADDRESS, &error);
|
||||
&m_exe_ctx, command[0].ref(), LLDB_INVALID_ADDRESS, &error);
|
||||
|
||||
if (addr == LLDB_INVALID_ADDRESS) {
|
||||
result.AppendError("invalid address expression\n");
|
||||
@@ -1442,10 +1442,10 @@ protected:
|
||||
// Be careful, getAsInteger with a radix of 16 rejects "0xab" so we
|
||||
// have to special case that:
|
||||
bool success = false;
|
||||
if (entry.ref.startswith("0x"))
|
||||
success = !entry.ref.getAsInteger(0, uval64);
|
||||
if (entry.ref().startswith("0x"))
|
||||
success = !entry.ref().getAsInteger(0, uval64);
|
||||
if (!success)
|
||||
success = !entry.ref.getAsInteger(16, uval64);
|
||||
success = !entry.ref().getAsInteger(16, uval64);
|
||||
if (!success) {
|
||||
result.AppendErrorWithFormat(
|
||||
"'%s' is not a valid hex string value.\n", entry.c_str());
|
||||
@@ -1463,7 +1463,7 @@ protected:
|
||||
break;
|
||||
}
|
||||
case eFormatBoolean:
|
||||
uval64 = OptionArgParser::ToBoolean(entry.ref, false, &success);
|
||||
uval64 = OptionArgParser::ToBoolean(entry.ref(), false, &success);
|
||||
if (!success) {
|
||||
result.AppendErrorWithFormat(
|
||||
"'%s' is not a valid boolean string value.\n", entry.c_str());
|
||||
@@ -1474,7 +1474,7 @@ protected:
|
||||
break;
|
||||
|
||||
case eFormatBinary:
|
||||
if (entry.ref.getAsInteger(2, uval64)) {
|
||||
if (entry.ref().getAsInteger(2, uval64)) {
|
||||
result.AppendErrorWithFormat(
|
||||
"'%s' is not a valid binary string value.\n", entry.c_str());
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
@@ -1493,10 +1493,10 @@ protected:
|
||||
case eFormatCharArray:
|
||||
case eFormatChar:
|
||||
case eFormatCString: {
|
||||
if (entry.ref.empty())
|
||||
if (entry.ref().empty())
|
||||
break;
|
||||
|
||||
size_t len = entry.ref.size();
|
||||
size_t len = entry.ref().size();
|
||||
// Include the NULL for C strings...
|
||||
if (m_format_options.GetFormat() == eFormatCString)
|
||||
++len;
|
||||
@@ -1513,7 +1513,7 @@ protected:
|
||||
break;
|
||||
}
|
||||
case eFormatDecimal:
|
||||
if (entry.ref.getAsInteger(0, sval64)) {
|
||||
if (entry.ref().getAsInteger(0, sval64)) {
|
||||
result.AppendErrorWithFormat(
|
||||
"'%s' is not a valid signed decimal value.\n", entry.c_str());
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
@@ -1531,7 +1531,7 @@ protected:
|
||||
|
||||
case eFormatUnsigned:
|
||||
|
||||
if (!entry.ref.getAsInteger(0, uval64)) {
|
||||
if (!entry.ref().getAsInteger(0, uval64)) {
|
||||
result.AppendErrorWithFormat(
|
||||
"'%s' is not a valid unsigned decimal string value.\n",
|
||||
entry.c_str());
|
||||
@@ -1549,7 +1549,7 @@ protected:
|
||||
break;
|
||||
|
||||
case eFormatOctal:
|
||||
if (entry.ref.getAsInteger(8, uval64)) {
|
||||
if (entry.ref().getAsInteger(8, uval64)) {
|
||||
result.AppendErrorWithFormat(
|
||||
"'%s' is not a valid octal string value.\n", entry.c_str());
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
@@ -1635,7 +1635,7 @@ protected:
|
||||
|
||||
Status error;
|
||||
lldb::addr_t addr = OptionArgParser::ToAddress(
|
||||
&m_exe_ctx, command[0].ref, LLDB_INVALID_ADDRESS, &error);
|
||||
&m_exe_ctx, command[0].ref(), LLDB_INVALID_ADDRESS, &error);
|
||||
|
||||
if (addr == LLDB_INVALID_ADDRESS) {
|
||||
result.AppendError("invalid address expression");
|
||||
@@ -1700,7 +1700,7 @@ protected:
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
} else {
|
||||
if (command.GetArgumentCount() == 1) {
|
||||
auto load_addr_str = command[0].ref;
|
||||
auto load_addr_str = command[0].ref();
|
||||
load_addr = OptionArgParser::ToAddress(&m_exe_ctx, load_addr_str,
|
||||
LLDB_INVALID_ADDRESS, &error);
|
||||
if (error.Fail() || load_addr == LLDB_INVALID_ADDRESS) {
|
||||
|
||||
@@ -93,7 +93,7 @@ bool CommandObjectMultiword::Execute(const char *args_string,
|
||||
return result.Succeeded();
|
||||
}
|
||||
|
||||
auto sub_command = args[0].ref;
|
||||
auto sub_command = args[0].ref();
|
||||
if (sub_command.empty())
|
||||
return result.Succeeded();
|
||||
|
||||
@@ -180,7 +180,7 @@ void CommandObjectMultiword::GenerateHelpText(Stream &output_stream) {
|
||||
}
|
||||
|
||||
void CommandObjectMultiword::HandleCompletion(CompletionRequest &request) {
|
||||
auto arg0 = request.GetParsedLine()[0].ref;
|
||||
auto arg0 = request.GetParsedLine()[0].ref();
|
||||
if (request.GetCursorIndex() == 0) {
|
||||
StringList new_matches, descriptions;
|
||||
AddNamesMatchingPartialString(m_subcommand_dict, arg0, new_matches,
|
||||
@@ -225,7 +225,7 @@ const char *CommandObjectMultiword::GetRepeatCommand(Args ¤t_command_args,
|
||||
if (current_command_args.GetArgumentCount() <= index)
|
||||
return nullptr;
|
||||
CommandObject *sub_command_object =
|
||||
GetSubcommandObject(current_command_args[index].ref);
|
||||
GetSubcommandObject(current_command_args[index].ref());
|
||||
if (sub_command_object == nullptr)
|
||||
return nullptr;
|
||||
return sub_command_object->GetRepeatCommand(current_command_args, index);
|
||||
|
||||
@@ -1336,9 +1336,9 @@ protected:
|
||||
Stream &ostrm = result.GetOutputStream();
|
||||
for (auto &entry : args.entries()) {
|
||||
lldb::pid_t pid;
|
||||
if (entry.ref.getAsInteger(0, pid)) {
|
||||
if (entry.ref().getAsInteger(0, pid)) {
|
||||
result.AppendErrorWithFormat("invalid process ID argument '%s'",
|
||||
entry.ref.str().c_str());
|
||||
entry.ref().str().c_str());
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
break;
|
||||
} else {
|
||||
|
||||
@@ -57,7 +57,7 @@ protected:
|
||||
|
||||
Status error;
|
||||
|
||||
FileSpec dylib_fspec(command[0].ref);
|
||||
FileSpec dylib_fspec(command[0].ref());
|
||||
FileSystem::Instance().Resolve(dylib_fspec);
|
||||
|
||||
if (GetDebugger().LoadPlugin(dylib_fspec, error))
|
||||
|
||||
@@ -923,7 +923,7 @@ protected:
|
||||
for (auto &entry : command.entries()) {
|
||||
Status error;
|
||||
PlatformSP platform = process->GetTarget().GetPlatform();
|
||||
llvm::StringRef image_path = entry.ref;
|
||||
llvm::StringRef image_path = entry.ref();
|
||||
uint32_t image_token = LLDB_INVALID_IMAGE_TOKEN;
|
||||
|
||||
if (!m_options.do_install) {
|
||||
@@ -985,9 +985,9 @@ protected:
|
||||
|
||||
for (auto &entry : command.entries()) {
|
||||
uint32_t image_token;
|
||||
if (entry.ref.getAsInteger(0, image_token)) {
|
||||
if (entry.ref().getAsInteger(0, image_token)) {
|
||||
result.AppendErrorWithFormat("invalid image index argument '%s'",
|
||||
entry.ref.str().c_str());
|
||||
entry.ref().str().c_str());
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
break;
|
||||
} else {
|
||||
|
||||
@@ -206,7 +206,7 @@ protected:
|
||||
// consistent towards the user and allow them to say reg read $rbx -
|
||||
// internally, however, we should be strict and not allow ourselves
|
||||
// to call our registers $rbx in our own API
|
||||
auto arg_str = entry.ref;
|
||||
auto arg_str = entry.ref();
|
||||
arg_str.consume_front("$");
|
||||
|
||||
reg_info = reg_ctx->GetRegisterInfoByName(arg_str);
|
||||
@@ -335,8 +335,8 @@ protected:
|
||||
"register write takes exactly 2 arguments: <reg-name> <value>");
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
} else {
|
||||
auto reg_name = command[0].ref;
|
||||
auto value_str = command[1].ref;
|
||||
auto reg_name = command[0].ref();
|
||||
auto value_str = command[1].ref();
|
||||
|
||||
// in most LLDB commands we accept $rbx as the name for register RBX -
|
||||
// and here we would reject it and non-existant. we should be more
|
||||
|
||||
@@ -281,7 +281,7 @@ protected:
|
||||
if (!args.empty()) {
|
||||
for (const auto &arg : args) {
|
||||
Status error(GetDebugger().DumpPropertyValue(
|
||||
&m_exe_ctx, result.GetOutputStream(), arg.ref,
|
||||
&m_exe_ctx, result.GetOutputStream(), arg.ref(),
|
||||
OptionValue::eDumpGroupValue));
|
||||
if (error.Success()) {
|
||||
result.GetOutputStream().EOL();
|
||||
@@ -403,7 +403,7 @@ protected:
|
||||
|
||||
for (const auto &arg : args) {
|
||||
Status error(GetDebugger().DumpPropertyValue(
|
||||
&clean_ctx, out_file, arg.ref, OptionValue::eDumpGroupExport));
|
||||
&clean_ctx, out_file, arg.ref(), OptionValue::eDumpGroupExport));
|
||||
if (!error.Success()) {
|
||||
result.AppendError(error.AsCString());
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
|
||||
@@ -734,7 +734,7 @@ public:
|
||||
// the arguments directly.
|
||||
auto iter =
|
||||
llvm::find_if(current_command_args, [](const Args::ArgEntry &e) {
|
||||
return e.ref == "-r" || e.ref == "--reverse";
|
||||
return e.ref() == "-r" || e.ref() == "--reverse";
|
||||
});
|
||||
if (iter == current_command_args.end())
|
||||
return m_cmd_name.c_str();
|
||||
|
||||
@@ -625,7 +625,7 @@ protected:
|
||||
|
||||
for (auto &entry : args.entries()) {
|
||||
uint32_t target_idx;
|
||||
if (entry.ref.getAsInteger(0, target_idx)) {
|
||||
if (entry.ref().getAsInteger(0, target_idx)) {
|
||||
result.AppendErrorWithFormat("invalid target index '%s'\n",
|
||||
entry.c_str());
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
@@ -2550,10 +2550,10 @@ protected:
|
||||
}
|
||||
} else {
|
||||
for (auto &entry : args.entries()) {
|
||||
if (entry.ref.empty())
|
||||
if (entry.ref().empty())
|
||||
continue;
|
||||
|
||||
FileSpec file_spec(entry.ref);
|
||||
FileSpec file_spec(entry.ref());
|
||||
if (FileSystem::Instance().Exists(file_spec)) {
|
||||
ModuleSpec module_spec(file_spec);
|
||||
if (m_uuid_option_group.GetOptionValue().OptionWasSet())
|
||||
@@ -2583,10 +2583,10 @@ protected:
|
||||
} else {
|
||||
std::string resolved_path = file_spec.GetPath();
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
if (resolved_path != entry.ref) {
|
||||
if (resolved_path != entry.ref()) {
|
||||
result.AppendErrorWithFormat(
|
||||
"invalid module path '%s' with resolved path '%s'\n",
|
||||
entry.ref.str().c_str(), resolved_path.c_str());
|
||||
entry.ref().str().c_str(), resolved_path.c_str());
|
||||
break;
|
||||
}
|
||||
result.AppendErrorWithFormat("invalid module path '%s'\n",
|
||||
@@ -4303,9 +4303,9 @@ protected:
|
||||
PlatformSP platform_sp(target->GetPlatform());
|
||||
|
||||
for (auto &entry : args.entries()) {
|
||||
if (!entry.ref.empty()) {
|
||||
if (!entry.ref().empty()) {
|
||||
auto &symbol_file_spec = module_spec.GetSymbolFileSpec();
|
||||
symbol_file_spec.SetFile(entry.ref, FileSpec::Style::native);
|
||||
symbol_file_spec.SetFile(entry.ref(), FileSpec::Style::native);
|
||||
FileSystem::Instance().Resolve(symbol_file_spec);
|
||||
if (file_option_set) {
|
||||
module_spec.GetFileSpec() =
|
||||
@@ -4329,7 +4329,7 @@ protected:
|
||||
} else {
|
||||
std::string resolved_symfile_path =
|
||||
module_spec.GetSymbolFileSpec().GetPath();
|
||||
if (resolved_symfile_path != entry.ref) {
|
||||
if (resolved_symfile_path != entry.ref()) {
|
||||
result.AppendErrorWithFormat(
|
||||
"invalid module path '%s' with resolved path '%s'\n",
|
||||
entry.c_str(), resolved_symfile_path.c_str());
|
||||
|
||||
@@ -840,7 +840,7 @@ public:
|
||||
std::vector<Thread *> resume_threads;
|
||||
for (auto &entry : command.entries()) {
|
||||
uint32_t thread_idx;
|
||||
if (entry.ref.getAsInteger(0, thread_idx)) {
|
||||
if (entry.ref().getAsInteger(0, thread_idx)) {
|
||||
result.AppendErrorWithFormat(
|
||||
"invalid thread index argument: \"%s\".\n", entry.c_str());
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
|
||||
@@ -80,9 +80,9 @@ static bool WarnOnPotentialUnquotedUnsignedType(Args &command,
|
||||
return false;
|
||||
|
||||
for (auto entry : llvm::enumerate(command.entries().drop_back())) {
|
||||
if (entry.value().ref != "unsigned")
|
||||
if (entry.value().ref() != "unsigned")
|
||||
continue;
|
||||
auto next = command.entries()[entry.index() + 1].ref;
|
||||
auto next = command.entries()[entry.index() + 1].ref();
|
||||
if (next == "int" || next == "short" || next == "char" || next == "long") {
|
||||
result.AppendWarningWithFormat(
|
||||
"unsigned %s being treated as two types. if you meant the combined "
|
||||
@@ -679,15 +679,15 @@ protected:
|
||||
WarnOnPotentialUnquotedUnsignedType(command, result);
|
||||
|
||||
for (auto &arg_entry : command.entries()) {
|
||||
if (arg_entry.ref.empty()) {
|
||||
if (arg_entry.ref().empty()) {
|
||||
result.AppendError("empty typenames not allowed");
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
|
||||
ConstString typeCS(arg_entry.ref);
|
||||
ConstString typeCS(arg_entry.ref());
|
||||
if (m_command_options.m_regex) {
|
||||
RegularExpression typeRX(arg_entry.ref);
|
||||
RegularExpression typeRX(arg_entry.ref());
|
||||
if (!typeRX.IsValid()) {
|
||||
result.AppendError(
|
||||
"regex format error (maybe this is not really a regex?)");
|
||||
@@ -1328,13 +1328,13 @@ bool CommandObjectTypeSummaryAdd::Execute_ScriptSummary(
|
||||
m_options.m_name, m_options.m_category);
|
||||
|
||||
for (auto &entry : command.entries()) {
|
||||
if (entry.ref.empty()) {
|
||||
if (entry.ref().empty()) {
|
||||
result.AppendError("empty typenames not allowed");
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
|
||||
options->m_target_types << entry.ref;
|
||||
options->m_target_types << entry.ref();
|
||||
}
|
||||
|
||||
m_interpreter.GetPythonCommandsFromIOHandler(
|
||||
@@ -1355,7 +1355,7 @@ bool CommandObjectTypeSummaryAdd::Execute_ScriptSummary(
|
||||
|
||||
for (auto &entry : command.entries()) {
|
||||
CommandObjectTypeSummaryAdd::AddSummary(
|
||||
ConstString(entry.ref), script_format,
|
||||
ConstString(entry.ref()), script_format,
|
||||
(m_options.m_regex ? eRegexSummary : eRegularSummary),
|
||||
m_options.m_category, &error);
|
||||
if (error.Fail()) {
|
||||
@@ -1428,12 +1428,12 @@ bool CommandObjectTypeSummaryAdd::Execute_StringSummary(
|
||||
// now I have a valid format, let's add it to every type
|
||||
Status error;
|
||||
for (auto &arg_entry : command.entries()) {
|
||||
if (arg_entry.ref.empty()) {
|
||||
if (arg_entry.ref().empty()) {
|
||||
result.AppendError("empty typenames not allowed");
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
ConstString typeCS(arg_entry.ref);
|
||||
ConstString typeCS(arg_entry.ref());
|
||||
|
||||
AddSummary(typeCS, entry,
|
||||
(m_options.m_regex ? eRegexSummary : eRegularSummary),
|
||||
@@ -1786,7 +1786,7 @@ protected:
|
||||
|
||||
for (auto &entry : command.entries()) {
|
||||
TypeCategoryImplSP category_sp;
|
||||
if (DataVisualization::Categories::GetCategory(ConstString(entry.ref),
|
||||
if (DataVisualization::Categories::GetCategory(ConstString(entry.ref()),
|
||||
category_sp) &&
|
||||
category_sp) {
|
||||
category_sp->AddLanguage(m_options.m_cate_language.GetCurrentValue());
|
||||
@@ -2228,13 +2228,13 @@ bool CommandObjectTypeSynthAdd::Execute_HandwritePython(
|
||||
m_options.m_cascade, m_options.m_regex, m_options.m_category);
|
||||
|
||||
for (auto &entry : command.entries()) {
|
||||
if (entry.ref.empty()) {
|
||||
if (entry.ref().empty()) {
|
||||
result.AppendError("empty typenames not allowed");
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
|
||||
options->m_target_types << entry.ref;
|
||||
options->m_target_types << entry.ref();
|
||||
}
|
||||
|
||||
m_interpreter.GetPythonCommandsFromIOHandler(
|
||||
@@ -2293,13 +2293,13 @@ bool CommandObjectTypeSynthAdd::Execute_PythonClass(
|
||||
Status error;
|
||||
|
||||
for (auto &arg_entry : command.entries()) {
|
||||
if (arg_entry.ref.empty()) {
|
||||
if (arg_entry.ref().empty()) {
|
||||
result.AppendError("empty typenames not allowed");
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
|
||||
ConstString typeCS(arg_entry.ref);
|
||||
ConstString typeCS(arg_entry.ref());
|
||||
if (!AddSynth(typeCS, entry,
|
||||
m_options.m_regex ? eRegexSynth : eRegularSynth,
|
||||
m_options.m_category, &error)) {
|
||||
@@ -2594,13 +2594,13 @@ protected:
|
||||
WarnOnPotentialUnquotedUnsignedType(command, result);
|
||||
|
||||
for (auto &arg_entry : command.entries()) {
|
||||
if (arg_entry.ref.empty()) {
|
||||
if (arg_entry.ref().empty()) {
|
||||
result.AppendError("empty typenames not allowed");
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
|
||||
ConstString typeCS(arg_entry.ref);
|
||||
ConstString typeCS(arg_entry.ref());
|
||||
if (!AddFilter(typeCS, entry,
|
||||
m_options.m_regex ? eRegexFilter : eRegularFilter,
|
||||
m_options.m_category, &error)) {
|
||||
|
||||
@@ -89,12 +89,12 @@ bool CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(
|
||||
// Go through the arguments and make a canonical form of arg list containing
|
||||
// only numbers with possible "-" in between.
|
||||
for (auto &entry : args.entries()) {
|
||||
if ((idx = WithRSAIndex(entry.ref)) == -1) {
|
||||
StrRefArgs.push_back(entry.ref);
|
||||
if ((idx = WithRSAIndex(entry.ref())) == -1) {
|
||||
StrRefArgs.push_back(entry.ref());
|
||||
continue;
|
||||
}
|
||||
// The Arg contains the range specifier, split it, then.
|
||||
std::tie(first, second) = entry.ref.split(RSA[idx]);
|
||||
std::tie(first, second) = entry.ref().split(RSA[idx]);
|
||||
if (!first.empty())
|
||||
StrRefArgs.push_back(first);
|
||||
StrRefArgs.push_back(Minus);
|
||||
|
||||
@@ -64,8 +64,8 @@ static bool ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp,
|
||||
option_arg_vector->emplace_back("<argument>", -1, options_string);
|
||||
else {
|
||||
for (auto &entry : args.entries()) {
|
||||
if (!entry.ref.empty())
|
||||
option_arg_vector->emplace_back("<argument>", -1, entry.ref);
|
||||
if (!entry.ref().empty())
|
||||
option_arg_vector->emplace_back("<argument>", -1, entry.ref());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1961,7 +1961,7 @@ void CommandInterpreter::BuildAliasCommandArgs(CommandObject *alias_cmd_obj,
|
||||
|
||||
for (auto entry : llvm::enumerate(cmd_args.entries())) {
|
||||
if (!used[entry.index()] && !wants_raw_input)
|
||||
new_args.AppendArgument(entry.value().ref);
|
||||
new_args.AppendArgument(entry.value().ref());
|
||||
}
|
||||
|
||||
cmd_args.Clear();
|
||||
|
||||
@@ -967,7 +967,7 @@ bool CommandObjectParsed::Execute(const char *args_string,
|
||||
}
|
||||
if (!handled) {
|
||||
for (auto entry : llvm::enumerate(cmd_args.entries())) {
|
||||
if (!entry.value().ref.empty() && entry.value().ref.front() == '`') {
|
||||
if (!entry.value().ref().empty() && entry.value().ref().front() == '`') {
|
||||
cmd_args.ReplaceArgumentAtIndex(
|
||||
entry.index(),
|
||||
m_interpreter.ProcessEmbeddedScriptCommands(entry.value().c_str()));
|
||||
|
||||
@@ -111,18 +111,18 @@ Status OptionValueDictionary::SetArgs(const Args &args,
|
||||
return error;
|
||||
}
|
||||
for (const auto &entry : args) {
|
||||
if (entry.ref.empty()) {
|
||||
if (entry.ref().empty()) {
|
||||
error.SetErrorString("empty argument");
|
||||
return error;
|
||||
}
|
||||
if (!entry.ref.contains('=')) {
|
||||
if (!entry.ref().contains('=')) {
|
||||
error.SetErrorString(
|
||||
"assign operation takes one or more key=value arguments");
|
||||
return error;
|
||||
}
|
||||
|
||||
llvm::StringRef key, value;
|
||||
std::tie(key, value) = entry.ref.split('=');
|
||||
std::tie(key, value) = entry.ref().split('=');
|
||||
bool key_valid = false;
|
||||
if (key.empty()) {
|
||||
error.SetErrorString("empty dictionary key");
|
||||
|
||||
@@ -937,7 +937,7 @@ static Args ReconstituteArgsAfterParsing(llvm::ArrayRef<char *> parsed,
|
||||
for (const char *arg : parsed) {
|
||||
auto pos = FindOriginalIter(arg, original);
|
||||
assert(pos != original.end());
|
||||
result.AppendArgument(pos->ref, pos->GetQuoteChar());
|
||||
result.AppendArgument(pos->ref(), pos->GetQuoteChar());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -948,8 +948,8 @@ static size_t FindArgumentIndexForOption(const Args &args,
|
||||
std::string long_opt =
|
||||
llvm::formatv("--{0}", long_option.definition->long_option);
|
||||
for (const auto &entry : llvm::enumerate(args)) {
|
||||
if (entry.value().ref.startswith(short_opt) ||
|
||||
entry.value().ref.startswith(long_opt))
|
||||
if (entry.value().ref().startswith(short_opt) ||
|
||||
entry.value().ref().startswith(long_opt))
|
||||
return entry.index();
|
||||
}
|
||||
|
||||
@@ -1088,7 +1088,7 @@ llvm::Expected<Args> Options::ParseAlias(const Args &args,
|
||||
continue;
|
||||
|
||||
if (!input_line.empty()) {
|
||||
auto tmp_arg = args_copy[idx].ref;
|
||||
auto tmp_arg = args_copy[idx].ref();
|
||||
size_t pos = input_line.find(tmp_arg);
|
||||
if (pos != std::string::npos)
|
||||
input_line.erase(pos, tmp_arg.size());
|
||||
@@ -1098,9 +1098,9 @@ llvm::Expected<Args> Options::ParseAlias(const Args &args,
|
||||
OptionParser::eNoArgument) &&
|
||||
(OptionParser::GetOptionArgument() != nullptr) &&
|
||||
(idx < args_copy.GetArgumentCount()) &&
|
||||
(args_copy[idx].ref == OptionParser::GetOptionArgument())) {
|
||||
(args_copy[idx].ref() == OptionParser::GetOptionArgument())) {
|
||||
if (input_line.size() > 0) {
|
||||
auto tmp_arg = args_copy[idx].ref;
|
||||
auto tmp_arg = args_copy[idx].ref();
|
||||
size_t pos = input_line.find(tmp_arg);
|
||||
if (pos != std::string::npos)
|
||||
input_line.erase(pos, tmp_arg.size());
|
||||
@@ -1291,7 +1291,7 @@ OptionElementVector Options::ParseForCompletion(const Args &args,
|
||||
const Args::ArgEntry &cursor = args[cursor_index];
|
||||
if ((static_cast<int32_t>(dash_dash_pos) == -1 ||
|
||||
cursor_index < dash_dash_pos) &&
|
||||
!cursor.IsQuoted() && cursor.ref == "-") {
|
||||
!cursor.IsQuoted() && cursor.ref() == "-") {
|
||||
option_element_vector.push_back(
|
||||
OptionArgElement(OptionArgElement::eBareDash, cursor_index,
|
||||
OptionArgElement::eBareDash));
|
||||
|
||||
@@ -348,7 +348,7 @@ protected:
|
||||
bool demangled_any = false;
|
||||
bool error_any = false;
|
||||
for (auto &entry : command.entries()) {
|
||||
if (entry.ref.empty())
|
||||
if (entry.ref().empty())
|
||||
continue;
|
||||
|
||||
// the actual Mangled class should be strict about this, but on the
|
||||
@@ -356,7 +356,7 @@ protected:
|
||||
// they will come out with an extra underscore - be willing to strip this
|
||||
// on behalf of the user. This is the moral equivalent of the -_/-n
|
||||
// options to c++filt
|
||||
auto name = entry.ref;
|
||||
auto name = entry.ref();
|
||||
if (name.startswith("__Z"))
|
||||
name = name.drop_front();
|
||||
|
||||
@@ -365,12 +365,12 @@ protected:
|
||||
ConstString demangled(
|
||||
mangled.GetDisplayDemangledName(lldb::eLanguageTypeC_plus_plus));
|
||||
demangled_any = true;
|
||||
result.AppendMessageWithFormat("%s ---> %s\n", entry.ref.str().c_str(),
|
||||
result.AppendMessageWithFormat("%s ---> %s\n", entry.c_str(),
|
||||
demangled.GetCString());
|
||||
} else {
|
||||
error_any = true;
|
||||
result.AppendErrorWithFormat("%s is not a valid C++ mangled name\n",
|
||||
entry.ref.str().c_str());
|
||||
entry.ref().str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,6 @@ Args::ArgEntry::ArgEntry(llvm::StringRef str, char quote) : quote(quote) {
|
||||
|
||||
::memcpy(data(), str.data() ? str.data() : "", size);
|
||||
ptr[size] = 0;
|
||||
ref = llvm::StringRef(c_str(), size);
|
||||
}
|
||||
|
||||
// Args constructor
|
||||
@@ -182,7 +181,7 @@ Args &Args::operator=(const Args &rhs) {
|
||||
m_argv.clear();
|
||||
m_entries.clear();
|
||||
for (auto &entry : rhs.m_entries) {
|
||||
m_entries.emplace_back(entry.ref, entry.quote);
|
||||
m_entries.emplace_back(entry.ref(), entry.quote);
|
||||
m_argv.push_back(m_entries.back().data());
|
||||
}
|
||||
m_argv.push_back(nullptr);
|
||||
@@ -199,7 +198,7 @@ void Args::Dump(Stream &s, const char *label_name) const {
|
||||
int i = 0;
|
||||
for (auto &entry : m_entries) {
|
||||
s.Indent();
|
||||
s.Format("{0}[{1}]=\"{2}\"\n", label_name, i++, entry.ref);
|
||||
s.Format("{0}[{1}]=\"{2}\"\n", label_name, i++, entry.ref());
|
||||
}
|
||||
s.Format("{0}[{1}]=NULL\n", label_name, i);
|
||||
s.EOL();
|
||||
@@ -211,7 +210,7 @@ bool Args::GetCommandString(std::string &command) const {
|
||||
for (size_t i = 0; i < m_entries.size(); ++i) {
|
||||
if (i > 0)
|
||||
command += ' ';
|
||||
command += m_entries[i].ref;
|
||||
command += m_entries[i].ref();
|
||||
}
|
||||
|
||||
return !m_entries.empty();
|
||||
@@ -226,10 +225,10 @@ bool Args::GetQuotedCommandString(std::string &command) const {
|
||||
|
||||
if (m_entries[i].quote) {
|
||||
command += m_entries[i].quote;
|
||||
command += m_entries[i].ref;
|
||||
command += m_entries[i].ref();
|
||||
command += m_entries[i].quote;
|
||||
} else {
|
||||
command += m_entries[i].ref;
|
||||
command += m_entries[i].ref();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,7 +292,7 @@ void Args::AppendArguments(const Args &rhs) {
|
||||
assert(m_argv.back() == nullptr);
|
||||
m_argv.pop_back();
|
||||
for (auto &entry : rhs.m_entries) {
|
||||
m_entries.emplace_back(entry.ref, entry.quote);
|
||||
m_entries.emplace_back(entry.ref(), entry.quote);
|
||||
m_argv.push_back(m_entries.back().data());
|
||||
}
|
||||
m_argv.push_back(nullptr);
|
||||
|
||||
@@ -152,9 +152,9 @@ TEST(ArgsTest, StringListConstructor) {
|
||||
<< "baz";
|
||||
Args args(list);
|
||||
ASSERT_EQ(3u, args.GetArgumentCount());
|
||||
EXPECT_EQ("foo", args[0].ref);
|
||||
EXPECT_EQ("bar", args[1].ref);
|
||||
EXPECT_EQ("baz", args[2].ref);
|
||||
EXPECT_EQ("foo", args[0].ref());
|
||||
EXPECT_EQ("bar", args[1].ref());
|
||||
EXPECT_EQ("baz", args[2].ref());
|
||||
}
|
||||
|
||||
TEST(ArgsTest, GetQuotedCommandString) {
|
||||
|
||||
Reference in New Issue
Block a user