]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add comments to resolve_segments
authorOwen Avery <powerboat9.gamer@gmail.com>
Mon, 17 Feb 2025 23:33:08 +0000 (18:33 -0500)
committerPhilip Herron <philip.herron@embecosm.com>
Wed, 19 Feb 2025 08:36:23 +0000 (08:36 +0000)
gcc/rust/ChangeLog:

* resolve/rust-forever-stack.hxx
(ForeverStack::resolve_segments): Add comments explaining
the behaviour of a while loop.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/resolve/rust-forever-stack.hxx

index 39c623ccb066a87442ed3f4199265fefadb7b62f..5dd341397ef44bae3972eb61db1cf2648c66ab5a 100644 (file)
@@ -464,8 +464,17 @@ ForeverStack<N>::resolve_segments (
 
       tl::optional<typename ForeverStack<N>::Node &> child = tl::nullopt;
 
+      /*
+       * On every iteration this loop either
+       *
+       * 1. terminates
+       * 2. decreases the depth of the node pointed to by current_node
+       *
+       * This ensures termination
+       */
       while (true)
        {
+         // may set the value of child
          for (auto &kv : current_node->children)
            {
              auto &link = kv.first;
@@ -508,6 +517,8 @@ ForeverStack<N>::resolve_segments (
          current_node = &current_node->parent.value ();
        }
 
+      // if child didn't contain a value
+      // the while loop above should have return'd or kept looping
       current_node = &child.value ();
       insert_segment_resolution (outer_seg, current_node->id);
     }