[Lldb-commits] [lldb] [lldb] Return index of element in ValueObject path instead of the element's value (PR #74413)

Pete Lawrence via lldb-commits lldb-commits at lists.llvm.org
Tue Dec 5 16:57:40 PST 2023


================
@@ -398,13 +398,16 @@ ValueObject::GetChildAtIndexPath(llvm::ArrayRef<size_t> 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;
----------------
PortalPete wrote:

I take it you're referring to [Swift evolution's proposal 0004 - Remove the `++` and `--` operators](https://github.com/apple/swift-evolution/blob/main/proposals/0004-remove-pre-post-inc-decrement.md).

As a coding and computer science mentor and writer, I naturally agree with Chris Lattner in that any code I write may serves as potential educational material to the reader/maintainer. For me, there are more cons than pros to the pre- and post-increment operators when I look at them through an educational lens.

https://github.com/llvm/llvm-project/pull/74413


More information about the lldb-commits mailing list