From: Owen Avery Date: Mon, 17 Feb 2025 23:33:08 +0000 (-0500) Subject: gccrs: Add comments to resolve_segments X-Git-Tag: basepoints/gcc-16~747 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c92dfc78201f73b5682851bffaa4e596adf66f2d;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/rust/resolve/rust-forever-stack.hxx b/gcc/rust/resolve/rust-forever-stack.hxx index d2020554f74..8abe8a61acb 100644 --- a/gcc/rust/resolve/rust-forever-stack.hxx +++ b/gcc/rust/resolve/rust-forever-stack.hxx @@ -464,8 +464,17 @@ ForeverStack::resolve_segments ( tl::optional::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::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); }