From: Tom de Vries Date: Thu, 23 Apr 2026 06:35:28 +0000 (+0200) Subject: Use block::super_blocks X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0466235aa7e9346eeda1a81fa73bb0b9986fd927;p=thirdparty%2Fbinutils-gdb.git Use block::super_blocks Use block::super_blocks in a few locations to simplify code. --- diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 71a338ce17e..da6c3b04dd9 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13825,9 +13825,7 @@ public: /* Search upwards from currently selected frame (so that we can complete on local vars. */ - for (const block *b = get_selected_block (0); - b != nullptr; - b = b->superblock ()) + for (auto b : block::super_blocks (get_selected_block (0))) { if (b->is_static_block ()) surrounding_static_block = b; /* For elmin of dups */ @@ -13852,9 +13850,8 @@ public: auto callback = [&] (compunit_symtab *s) { QUIT; - for (const block *b = s->blockvector ()->static_block (); - b != nullptr; - b = b->superblock ()) + for (auto b + : block::super_blocks (s->blockvector ()->static_block ())) { /* Don't do this block twice. */ if (b == surrounding_static_block) diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 89374bd8a2f..5a34986ebc2 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -961,11 +961,10 @@ block_depth (const struct block *block) { int i = 0; - while ((block = block->superblock ()) != NULL) - { - i++; - } - return i; + for (auto b [[maybe_unused]]: block::super_blocks (block)) + i++; + + return i - 1; }