diff options
| author | Raphael Isemann <teemperor@gmail.com> | 2019-11-25 15:03:46 +0100 |
|---|---|---|
| committer | Raphael Isemann <teemperor@gmail.com> | 2019-11-25 15:03:46 +0100 |
| commit | d1782133d96d316c3bc98e33a191994794a26851 (patch) | |
| tree | b34395755e063b8df5d970569a6d8421d78e9d64 /lldb/source/Core | |
| parent | d9c9a4e48d286a04d09a8fdea87f486a9ec02cd0 (diff) | |
| download | bcm5719-llvm-d1782133d96d316c3bc98e33a191994794a26851.tar.gz bcm5719-llvm-d1782133d96d316c3bc98e33a191994794a26851.zip | |
[lldb][NFC] Allow range-based for-loops on VariableList
Summary:
Adds support for doing range-based for-loops on LLDB's VariableList and
modernises all the index-based for-loops in LLDB where possible.
Reviewers: labath, jdoerfert
Reviewed By: labath
Subscribers: JDevlieghere, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70668
Diffstat (limited to 'lldb/source/Core')
| -rw-r--r-- | lldb/source/Core/Address.cpp | 14 | ||||
| -rw-r--r-- | lldb/source/Core/IOHandler.cpp | 7 |
2 files changed, 9 insertions, 12 deletions
diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp index a3912bef5a6..3313b598090 100644 --- a/lldb/source/Core/Address.cpp +++ b/lldb/source/Core/Address.cpp @@ -712,22 +712,20 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, [](Variable *) { return true; }, &variable_list); - const size_t num_variables = variable_list.GetSize(); - for (size_t var_idx = 0; var_idx < num_variables; ++var_idx) { - Variable *var = variable_list.GetVariableAtIndex(var_idx).get(); - if (var && var->LocationIsValidForAddress(*this)) { + for (const VariableSP &var_sp : variable_list) { + if (var_sp && var_sp->LocationIsValidForAddress(*this)) { s->Indent(); s->Printf(" Variable: id = {0x%8.8" PRIx64 "}, name = \"%s\"", - var->GetID(), var->GetName().GetCString()); - Type *type = var->GetType(); + var_sp->GetID(), var_sp->GetName().GetCString()); + Type *type = var_sp->GetType(); if (type) s->Printf(", type = \"%s\"", type->GetName().GetCString()); else s->PutCString(", type = <unknown>"); s->PutCString(", location = "); - var->DumpLocationForAddress(s, *this); + var_sp->DumpLocationForAddress(s, *this); s->PutCString(", decl = "); - var->GetDeclaration().DumpStopContext(s, false); + var_sp->GetDeclaration().DumpStopContext(s, false); s->EOL(); } } diff --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp index 46be29f6fbf..d11248094e0 100644 --- a/lldb/source/Core/IOHandler.cpp +++ b/lldb/source/Core/IOHandler.cpp @@ -3002,10 +3002,9 @@ public: VariableList *locals = frame->GetVariableList(true); if (locals) { const DynamicValueType use_dynamic = eDynamicDontRunTarget; - const size_t num_locals = locals->GetSize(); - for (size_t i = 0; i < num_locals; ++i) { - ValueObjectSP value_sp = frame->GetValueObjectForFrameVariable( - locals->GetVariableAtIndex(i), use_dynamic); + for (const VariableSP &local_sp : *locals) { + ValueObjectSP value_sp = + frame->GetValueObjectForFrameVariable(local_sp, use_dynamic); if (value_sp) { ValueObjectSP synthetic_value_sp = value_sp->GetSyntheticValue(); if (synthetic_value_sp) |

