[Lldb-commits] [lldb] 51b3874 - Convert for loops to entry-based iteration
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Thu Apr 2 09:57:04 PDT 2020
Author: Shivam Mittal
Date: 2020-04-02T18:56:29+02:00
New Revision: 51b38746295fc18664f766fe6cb7974b862c28eb
URL: https://github.com/llvm/llvm-project/commit/51b38746295fc18664f766fe6cb7974b862c28eb
DIFF: https://github.com/llvm/llvm-project/commit/51b38746295fc18664f766fe6cb7974b862c28eb.diff
LOG: Convert for loops to entry-based iteration
Summary: Convert index-based loops marked TODO in CommandObjectSettings and CommandObjectTarget to entry-based.
Reviewers: labath
Reviewed By: labath
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D76729
Added:
Modified:
lldb/source/Commands/CommandObjectSettings.cpp
lldb/source/Commands/CommandObjectTarget.cpp
Removed:
################################################################################
diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp
index cc1080c8cc0c..87e0352636e1 100644
--- a/lldb/source/Commands/CommandObjectSettings.cpp
+++ b/lldb/source/Commands/CommandObjectSettings.cpp
@@ -531,10 +531,8 @@ class CommandObjectSettingsList : public CommandObjectParsed {
if (argc > 0) {
const bool dump_qualified_name = true;
- // TODO: Convert to StringRef based enumeration. Requires converting
- // GetPropertyAtPath first.
- for (size_t i = 0; i < argc; ++i) {
- const char *property_path = args.GetArgumentAtIndex(i);
+ for (const Args::ArgEntry &arg : args) {
+ const char *property_path = arg.c_str();
const Property *property =
GetDebugger().GetValueProperties()->GetPropertyAtPath(
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index fb2854d90ba8..decdd9c53de2 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -876,21 +876,18 @@ class CommandObjectTargetVariable : public CommandObjectParsed {
Stream &s = result.GetOutputStream();
if (argc > 0) {
-
- // TODO: Convert to entry-based iteration. Requires converting
- // DumpValueObject.
- for (size_t idx = 0; idx < argc; ++idx) {
+ for (const Args::ArgEntry &arg : args) {
VariableList variable_list;
ValueObjectList valobj_list;
- const char *arg = args.GetArgumentAtIndex(idx);
size_t matches = 0;
bool use_var_name = false;
if (m_option_variable.use_regex) {
- RegularExpression regex(llvm::StringRef::withNullAsEmpty(arg));
+ RegularExpression regex(
+ llvm::StringRef::withNullAsEmpty(arg.c_str()));
if (!regex.IsValid()) {
result.GetErrorStream().Printf(
- "error: invalid regular expression: '%s'\n", arg);
+ "error: invalid regular expression: '%s'\n", arg.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -900,14 +897,14 @@ class CommandObjectTargetVariable : public CommandObjectParsed {
matches = variable_list.GetSize();
} else {
Status error(Variable::GetValuesForVariableExpressionPath(
- arg, m_exe_ctx.GetBestExecutionContextScope(),
+ arg.c_str(), m_exe_ctx.GetBestExecutionContextScope(),
GetVariableCallback, target, variable_list, valobj_list));
matches = variable_list.GetSize();
}
if (matches == 0) {
result.GetErrorStream().Printf(
- "error: can't find global variable '%s'\n", arg);
+ "error: can't find global variable '%s'\n", arg.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
} else {
@@ -923,7 +920,7 @@ class CommandObjectTargetVariable : public CommandObjectParsed {
if (valobj_sp)
DumpValueObject(s, var_sp, valobj_sp,
use_var_name ? var_sp->GetName().GetCString()
- : arg);
+ : arg.c_str());
}
}
}
@@ -3058,17 +3055,14 @@ class CommandObjectTargetModulesList : public CommandObjectParsed {
module_list_ptr = &target->GetImages();
}
} else {
- // TODO: Convert to entry based iteration. Requires converting
- // FindModulesByName.
- for (size_t i = 0; i < argc; ++i) {
+ for (const Args::ArgEntry &arg : command) {
// Dump specified images (by basename or fullpath)
- const char *arg_cstr = command.GetArgumentAtIndex(i);
const size_t num_matches = FindModulesByName(
- target, arg_cstr, module_list, use_global_module_list);
+ target, arg.c_str(), module_list, use_global_module_list);
if (num_matches == 0) {
if (argc == 1) {
result.AppendErrorWithFormat("no modules found that match '%s'",
- arg_cstr);
+ arg.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}
More information about the lldb-commits
mailing list