]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use block::super_blocks
authorTom de Vries <tdevries@suse.de>
Thu, 23 Apr 2026 06:35:28 +0000 (08:35 +0200)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 30 Apr 2026 15:00:32 +0000 (11:00 -0400)
Use block::super_blocks in a few locations to simplify code.

gdb/ada-lang.c
gdb/symmisc.c

index 71a338ce17efabc0661d2e5fe5c095edac108f43..da6c3b04dd994947ba103af38e8f46a284b23a09 100644 (file)
@@ -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)
index 89374bd8a2ffe256249caedd91e84c631bded4c7..5a34986ebc241c2ffaebb8577f943dc5452fbccd 100644 (file)
@@ -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;
 }
 \f