diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 20b3086138457..a158199e7fab1 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -468,7 +468,7 @@ class ValueObject { virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create = true); - // this will always create the children if necessary + // The method always creates missing children in the path, if necessary. lldb::ValueObjectSP GetChildAtIndexPath(llvm::ArrayRef idxs, size_t *index_of_error = nullptr); @@ -476,7 +476,7 @@ class ValueObject { GetChildAtIndexPath(llvm::ArrayRef> idxs, size_t *index_of_error = nullptr); - // this will always create the children if necessary + // The method always creates missing children in the path, if necessary. lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef names); virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name, diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index a7f7ee64282d8..b13bffa0ca809 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -398,13 +398,16 @@ ValueObject::GetChildAtIndexPath(llvm::ArrayRef idxs, if (idxs.size() == 0) return GetSP(); ValueObjectSP root(GetSP()); + + size_t current_index = 0; for (size_t idx : idxs) { root = root->GetChildAtIndex(idx); if (!root) { if (index_of_error) - *index_of_error = idx; + *index_of_error = current_index; return root; } + current_index += 1; } return root; } @@ -414,13 +417,17 @@ lldb::ValueObjectSP ValueObject::GetChildAtIndexPath( if (idxs.size() == 0) return GetSP(); ValueObjectSP root(GetSP()); + + size_t current_index = 0; for (std::pair idx : idxs) { root = root->GetChildAtIndex(idx.first, idx.second); if (!root) { if (index_of_error) - *index_of_error = idx.first; + *index_of_error = current_index; return root; } + + current_index += 1; } return root; }