]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Return references from compunit_symtab iterator
authorTom Tromey <tom@tromey.com>
Wed, 8 Oct 2025 23:29:34 +0000 (17:29 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 11 Oct 2025 19:40:32 +0000 (13:40 -0600)
This changes the compunit_symtab iterator to return references rather
than pointers, following the style of some other recent changes.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/ada-lang.c
gdb/coffread.c
gdb/maint.c
gdb/objfiles.c
gdb/objfiles.h
gdb/source.c
gdb/symfile-debug.c
gdb/symmisc.c
gdb/symtab.c

index ac6270d54f07816b45d4236282ce09571ce6ff1c..4d363e643bbccb9dc8599df8328537e38db8bdb4 100644 (file)
@@ -5588,10 +5588,10 @@ add_nonlocal_symbols (std::vector<struct block_symbol> &result,
     {
       map_matching_symbols (&objfile, lookup_name, domain, global, data);
 
-      for (compunit_symtab *cu : objfile.compunits ())
+      for (compunit_symtab &cu : objfile.compunits ())
        {
          const struct block *global_block
-           = cu->blockvector ()->global_block ();
+           = cu.blockvector ()->global_block ();
 
          if (ada_add_block_renamings (result, global_block, lookup_name,
                                       domain))
index 44e761abe89acfc1ea80e2caaa92a0db790e1b35..0a3be97c8d80de04ba0131b8af0db50599888bb6 100644 (file)
@@ -1256,9 +1256,9 @@ coff_symtab_read (minimal_symbol_reader &reader,
   /* Patch up any opaque types (references to types that are not defined
      in the file where they are referenced, e.g. "struct foo *bar").  */
   {
-    for (compunit_symtab *cu : objfile->compunits ())
+    for (compunit_symtab &cu : objfile->compunits ())
       {
-       for (symtab *s : cu->filetabs ())
+       for (symtab *s : cu.filetabs ())
          patch_opaque_types (s);
       }
   }
index 576582925c63d7fe4a4513fa0bbcd98e4c98bc5b..84847939a620062528da54419b569390346ccb2d 100644 (file)
@@ -972,12 +972,12 @@ count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr,
     {
       for (objfile &o : current_program_space->objfiles ())
        {
-         for (compunit_symtab *cu : o.compunits ())
+         for (compunit_symtab &cu : o.compunits ())
            {
              ++nr_compunit_symtabs;
-             nr_blocks += cu->blockvector ()->num_blocks ();
-             nr_symtabs += std::distance (cu->filetabs ().begin (),
-                                          cu->filetabs ().end ());
+             nr_blocks += cu.blockvector ()->num_blocks ();
+             nr_symtabs += std::distance (cu.filetabs ().begin (),
+                                          cu.filetabs ().end ());
            }
        }
     }
index 482e12e717f2de849716282782980c365cdc6daa..bc909db7d0e1d22fc604242b8f596e58f65d3454 100644 (file)
@@ -548,9 +548,9 @@ objfile_relocate1 (struct objfile *objfile,
     return 0;
 
   /* OK, get all the symtabs.  */
-  for (compunit_symtab *cust : objfile->compunits ())
+  for (compunit_symtab &cust : objfile->compunits ())
     {
-      struct blockvector *bv = cust->blockvector ();
+      struct blockvector *bv = cust.blockvector ();
       int block_line_section = SECT_OFF_TEXT (objfile);
 
       if (bv->map () != nullptr)
index 0f9c7709d06e1e90a4950d8b53561a0f54d6d54d..9566acfe33b005392e91e46baffc7579813f0b38 100644 (file)
@@ -34,7 +34,6 @@
 #include <forward_list>
 #include "gdbsupport/unordered_map.h"
 #include "gdbsupport/owning_intrusive_list.h"
-#include "gdbsupport/reference-to-pointer-iterator.h"
 
 struct htab;
 struct objfile_data;
@@ -474,7 +473,7 @@ public:
   program_space *pspace () { return m_pspace; }
 
   using compunit_symtab_iterator
-    = reference_to_pointer_iterator<owning_intrusive_list<compunit_symtab>::iterator>;
+    = owning_intrusive_list<compunit_symtab>::iterator;
   using compunit_symtab_range = iterator_range<compunit_symtab_iterator>;
 
   /* A range adapter that makes it possible to iterate over all
index aaafa1cf78819280620d323215c2d8e3aafb2746..1018d2ce6be34663e7ca0bf13105ab8f45501f6e 100644 (file)
@@ -356,9 +356,9 @@ select_source_symtab ()
 
   for (objfile &ofp : current_program_space->objfiles ())
     {
-      for (compunit_symtab *cu : ofp.compunits ())
+      for (compunit_symtab &cu : ofp.compunits ())
        {
-         for (symtab *symtab : cu->filetabs ())
+         for (symtab *symtab : cu.filetabs ())
            {
              const char *name = symtab->filename;
              int len = strlen (name);
index 55e8a5e2a596f136a6db1bec8b09c675290fcab2..b402a87b7a75165def4255477e1a81c55c30959d 100644 (file)
@@ -152,8 +152,8 @@ objfile::forget_cached_source_info ()
     gdb_printf (gdb_stdlog, "qf->forget_cached_source_info (%s)\n",
                objfile_debug_name (this));
 
-  for (compunit_symtab *cu : compunits ())
-    cu->forget_cached_source_info ();
+  for (compunit_symtab &cu : compunits ())
+    cu.forget_cached_source_info ();
 
   for (const auto &iter : qf)
     iter->forget_cached_source_info (this);
index f031d00a77e586634acf2ea9dfbd73d789d839fe..2ad3620c9f27c5b1e25a83153178d2ceac6cb3aa 100644 (file)
@@ -73,9 +73,9 @@ print_objfile_statistics (void)
                      OBJSTAT ((&objfile), n_types));
 
        i = linetables = 0;
-       for (compunit_symtab *cu : objfile.compunits ())
+       for (compunit_symtab &cu : objfile.compunits ())
          {
-           for (symtab *s : cu->filetabs ())
+           for (symtab *s : cu.filetabs ())
              {
                i++;
                if (s->linetable () != NULL)
@@ -123,7 +123,7 @@ dump_objfile (struct objfile *objfile)
   objfile->dump ();
 
   bool symtabs_printed = false;
-  for (compunit_symtab *cu : objfile->compunits ())
+  for (compunit_symtab &cu : objfile->compunits ())
     {
       if (!symtabs_printed)
        {
@@ -131,7 +131,7 @@ dump_objfile (struct objfile *objfile)
          symtabs_printed = true;
        }
 
-      for (symtab *symtab : cu->filetabs ())
+      for (symtab *symtab : cu.filetabs ())
        {
          gdb_printf ("%s at %s",
                      symtab_to_filename_for_display (symtab),
@@ -468,9 +468,9 @@ maintenance_print_symbols (const char *args, int from_tty)
          if (!print_for_objfile)
            continue;
 
-         for (compunit_symtab *cu : objfile.compunits ())
+         for (compunit_symtab &cu : objfile.compunits ())
            {
-             for (symtab *s : cu->filetabs ())
+             for (symtab *s : cu.filetabs ())
                {
                  int print_for_source = 0;
 
@@ -751,11 +751,11 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
           actually find a symtab whose name matches.  */
        int printed_objfile_start = 0;
 
-       for (compunit_symtab *cust : objfile.compunits ())
+       for (compunit_symtab &cust : objfile.compunits ())
          {
            int printed_compunit_symtab_start = 0;
 
-           for (symtab *symtab : cust->filetabs ())
+           for (symtab *symtab : cust.filetabs ())
              {
                QUIT;
 
@@ -773,32 +773,32 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
                    if (! printed_compunit_symtab_start)
                      {
                        gdb_printf ("  { ((struct compunit_symtab *) %s)\n",
-                                   host_address_to_string (cust));
+                                   host_address_to_string (&cust));
                        gdb_printf ("    debugformat %s\n",
-                                   cust->debugformat ());
+                                   cust.debugformat ());
                        gdb_printf ("    producer %s\n",
-                                   (cust->producer () != nullptr
-                                    ? cust->producer () : "(null)"));
-                       gdb_printf ("    name %s\n", cust->name);
+                                   (cust.producer () != nullptr
+                                    ? cust.producer () : "(null)"));
+                       gdb_printf ("    name %s\n", cust.name);
                        gdb_printf ("    dirname %s\n",
-                                   (cust->dirname () != NULL
-                                    ? cust->dirname () : "(null)"));
+                                   (cust.dirname () != NULL
+                                    ? cust.dirname () : "(null)"));
                        gdb_printf ("    blockvector"
                                    " ((struct blockvector *) %s)\n",
                                    host_address_to_string
-                                   (cust->blockvector ()));
+                                   (cust.blockvector ()));
                        gdb_printf ("    user"
                                    " ((struct compunit_symtab *) %s)\n",
-                                   cust->user != nullptr
-                                   ? host_address_to_string (cust->user)
+                                   cust.user != nullptr
+                                   ? host_address_to_string (cust.user)
                                    : "(null)");
-                       if (cust->includes != nullptr)
+                       if (cust.includes != nullptr)
                          {
                            gdb_printf ("    ( includes\n");
                            for (int i = 0; ; ++i)
                              {
                                struct compunit_symtab *include
-                                 = cust->includes[i];
+                                 = cust.includes[i];
                                if (include == nullptr)
                                  break;
                                const char *addr
@@ -856,14 +856,14 @@ maintenance_check_symtabs (const char *ignore, int from_tty)
           actually find something worth printing.  */
        int printed_objfile_start = 0;
 
-       for (compunit_symtab *cust : objfile.compunits ())
+       for (compunit_symtab &cust : objfile.compunits ())
          {
            int found_something = 0;
-           struct symtab *symtab = cust->primary_filetab ();
+           struct symtab *symtab = cust.primary_filetab ();
 
            QUIT;
 
-           if (cust->blockvector () == NULL)
+           if (cust.blockvector () == NULL)
              found_something = 1;
            /* Add more checks here.  */
 
@@ -879,7 +879,7 @@ maintenance_check_symtabs (const char *ignore, int from_tty)
                  }
                gdb_printf ("  { symtab %s\n",
                            symtab_to_filename_for_display (symtab));
-               if (cust->blockvector () == NULL)
+               if (cust.blockvector () == NULL)
                  gdb_printf ("    NULL blockvector\n");
                gdb_printf ("  }\n");
              }
@@ -1036,9 +1036,9 @@ maintenance_info_line_tables (const char *regexp, int from_tty)
   for (struct program_space *pspace : program_spaces)
     for (objfile &objfile : pspace->objfiles ())
       {
-       for (compunit_symtab *cust : objfile.compunits ())
+       for (compunit_symtab &cust : objfile.compunits ())
          {
-           for (symtab *symtab : cust->filetabs ())
+           for (symtab *symtab : cust.filetabs ())
              {
                QUIT;
 
index e24b31c528dc9997791bce16faf754adc1f122c5..d4089c877929b8934d6e7e3db0e5365b7d300751 100644 (file)
@@ -2251,14 +2251,14 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
 
   lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
   best_symbol_tracker accum;
-  for (compunit_symtab *cust : objfile->compunits ())
+  for (compunit_symtab &cust : objfile->compunits ())
     {
       const struct blockvector *bv;
       const struct block *block;
 
-      bv = cust->blockvector ();
+      bv = cust.blockvector ();
       block = bv->block (block_index);
-      if (accum.search (cust, block, lookup_name, domain))
+      if (accum.search (&cust, block, lookup_name, domain))
        break;
     }
 
@@ -2738,9 +2738,9 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
 
   for (objfile &obj_file : current_program_space->objfiles ())
     {
-      for (compunit_symtab *cust : obj_file.compunits ())
+      for (compunit_symtab &cust : obj_file.compunits ())
        {
-         const struct blockvector *bv = cust->blockvector ();
+         const struct blockvector *bv = cust.blockvector ();
          const struct block *global_block = bv->global_block ();
          CORE_ADDR start = global_block->start ();
          CORE_ADDR end = global_block->end ();
@@ -2753,7 +2753,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
              if (bv->map ()->find (pc) == nullptr)
                continue;
 
-             return cust;
+             return &cust;
            }
 
          CORE_ADDR range = end - start;
@@ -2799,7 +2799,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
            }
 
          /* Cust is best found so far, save it.  */
-         best_cust = cust;
+         best_cust = &cust;
          best_cust_range = range;
        }
     }
@@ -2861,9 +2861,9 @@ find_symbol_at_address (CORE_ADDR address)
         search the symtabs directly.  */
       if ((objfile.flags & OBJF_READNOW) != 0)
        {
-         for (compunit_symtab *symtab : objfile.compunits ())
+         for (compunit_symtab &symtab : objfile.compunits ())
            {
-             struct symbol *sym = search_symtab (symtab, address);
+             struct symbol *sym = search_symtab (&symtab, address);
              if (sym != nullptr)
                return sym;
            }
@@ -3303,9 +3303,9 @@ find_line_symtab (symtab *sym_tab, int line, int *index)
 
       for (objfile &objfile : current_program_space->objfiles ())
        {
-         for (compunit_symtab *cu : objfile.compunits ())
+         for (compunit_symtab &cu : objfile.compunits ())
            {
-             for (symtab *s : cu->filetabs ())
+             for (symtab *s : cu.filetabs ())
                {
                  const struct linetable *l;
                  int ind;
@@ -4537,9 +4537,9 @@ info_sources_worker (struct ui_out *uiout,
          sources_list.emplace (uiout, "sources");
        }
 
-      for (compunit_symtab *cu : objfile.compunits ())
+      for (compunit_symtab &cu : objfile.compunits ())
        {
-         for (symtab *s : cu->filetabs ())
+         for (symtab *s : cu.filetabs ())
            {
              const char *file = symtab_to_filename_for_display (s);
              const char *fullname = symtab_to_fullname (s);
@@ -4790,9 +4790,9 @@ global_symbol_searcher::add_matching_symbols
   domain_search_flags kind = m_kind;
 
   /* Add matching symbols (if not already present).  */
-  for (compunit_symtab *cust : objfile->compunits ())
+  for (compunit_symtab &cust : objfile->compunits ())
     {
-      const struct blockvector *bv  = cust->blockvector ();
+      const struct blockvector *bv  = cust.blockvector ();
 
       for (block_enum block : { GLOBAL_BLOCK, STATIC_BLOCK })
        {
@@ -6221,9 +6221,9 @@ make_source_files_completion_list (const char *text)
 
   for (objfile &objfile : current_program_space->objfiles ())
     {
-      for (compunit_symtab *cu : objfile.compunits ())
+      for (compunit_symtab &cu : objfile.compunits ())
        {
-         for (symtab *s : cu->filetabs ())
+         for (symtab *s : cu.filetabs ())
            {
              if (not_interesting_fname (s->filename))
                continue;