diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2025-02-17 18:33:08 -0500 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-24 13:07:07 +0100 |
commit | c92dfc78201f73b5682851bffaa4e596adf66f2d (patch) | |
tree | 33b578dc64689c0cd5f5ef68e15a49735c93933d /gcc/rust/resolve/rust-forever-stack.hxx | |
parent | 75db9aed8d9103f180acb9630603be0858ac87d2 (diff) | |
download | gcc-c92dfc78201f73b5682851bffaa4e596adf66f2d.zip gcc-c92dfc78201f73b5682851bffaa4e596adf66f2d.tar.gz gcc-c92dfc78201f73b5682851bffaa4e596adf66f2d.tar.bz2 |
gccrs: Add comments to resolve_segments
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>
Diffstat (limited to 'gcc/rust/resolve/rust-forever-stack.hxx')
-rw-r--r-- | gcc/rust/resolve/rust-forever-stack.hxx | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/rust/resolve/rust-forever-stack.hxx b/gcc/rust/resolve/rust-forever-stack.hxx index d202055..8abe8a6 100644 --- a/gcc/rust/resolve/rust-forever-stack.hxx +++ b/gcc/rust/resolve/rust-forever-stack.hxx @@ -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 = ¤t_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); } |