]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove ALL_OBJFILE_COMPUNITS
authorTom Tromey <tom@tromey.com>
Sat, 24 Nov 2018 16:00:42 +0000 (09:00 -0700)
committerTom Tromey <tom@tromey.com>
Thu, 10 Jan 2019 01:28:15 +0000 (18:28 -0700)
This removes ALL_OBJFILE_COMPUNITS, replacing its uses with ranged for
loops.  Because ALL_COMPUNITS is also updated, in some places a
declaration must be deleted to avoid shadowing.

gdb/ChangeLog
2019-01-09  Tom Tromey  <tom@tromey.com>

* source.c (select_source_symtab)
(forget_cached_source_info_for_objfile): Remove declaration.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Remove
declaration.
* maint.c (count_symtabs_and_blocks): Remove declaration.
* cp-support.c (add_symbol_overload_list_qualified): Remove
declaration.
* coffread.c (coff_symtab_read): Remove declaration.
* symtab.c (lookup_symbol_in_objfile_symtabs)
(basic_lookup_transparent_type_1): Use objfile_compunits.
(lookup_objfile_from_block, find_pc_sect_compunit_symtab)
(info_sources_command, search_symbols)
(default_collect_symbol_completion_matches_break_on)
(make_source_files_completion_list): Remove declaration.
* ada-lang.c (add_nonlocal_symbols): Use objfile_compunits.
(ada_collect_symbol_completion_matches)
(ada_add_global_exceptions): Remove declaration.
* linespec.c (iterate_over_all_matching_symtabs): Use
objfile_compunits.
* objfiles.h (ALL_OBJFILE_COMPUNITS): Remove.
(class objfile_compunits): New.
(ALL_COMPUNITS): Use objfile_compunits.
* symmisc.c (print_objfile_statistics, maintenance_info_symtabs)
(maintenance_check_symtabs, maintenance_info_line_tables): Use
objfile_compunits.
* objfiles.c (objfile_relocate1): Use objfile_compunits.

12 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/coffread.c
gdb/cp-support.c
gdb/linespec.c
gdb/maint.c
gdb/mi/mi-cmd-file.c
gdb/objfiles.c
gdb/objfiles.h
gdb/source.c
gdb/symmisc.c
gdb/symtab.c

index 08a80d870d2e129656bf31b6aae2392527177821..13dca51d0bd011fd497a8e73b8b8f2fd1cb1c102 100644 (file)
@@ -1,3 +1,32 @@
+2019-01-09  Tom Tromey  <tom@tromey.com>
+
+       * source.c (select_source_symtab)
+       (forget_cached_source_info_for_objfile): Remove declaration.
+       * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Remove
+       declaration.
+       * maint.c (count_symtabs_and_blocks): Remove declaration.
+       * cp-support.c (add_symbol_overload_list_qualified): Remove
+       declaration.
+       * coffread.c (coff_symtab_read): Remove declaration.
+       * symtab.c (lookup_symbol_in_objfile_symtabs)
+       (basic_lookup_transparent_type_1): Use objfile_compunits.
+       (lookup_objfile_from_block, find_pc_sect_compunit_symtab)
+       (info_sources_command, search_symbols)
+       (default_collect_symbol_completion_matches_break_on)
+       (make_source_files_completion_list): Remove declaration.
+       * ada-lang.c (add_nonlocal_symbols): Use objfile_compunits.
+       (ada_collect_symbol_completion_matches)
+       (ada_add_global_exceptions): Remove declaration.
+       * linespec.c (iterate_over_all_matching_symtabs): Use
+       objfile_compunits.
+       * objfiles.h (ALL_OBJFILE_COMPUNITS): Remove.
+       (class objfile_compunits): New.
+       (ALL_COMPUNITS): Use objfile_compunits.
+       * symmisc.c (print_objfile_statistics, maintenance_info_symtabs)
+       (maintenance_check_symtabs, maintenance_info_line_tables): Use
+       objfile_compunits.
+       * objfiles.c (objfile_relocate1): Use objfile_compunits.
+
 2019-01-09  Tom Tromey  <tom@tromey.com>
 
        * symtab.c (search_symbols)
index e23a6fafd27195ac972857de2631a88bad9b30e7..69c368a48b43455754d7df0a08bef9c82775bcb4 100644 (file)
@@ -5605,7 +5605,6 @@ add_nonlocal_symbols (struct obstack *obstackp,
                      const lookup_name_info &lookup_name,
                      domain_enum domain, int global)
 {
-  struct compunit_symtab *cu;
   struct match_data data;
 
   memset (&data, 0, sizeof data);
@@ -5630,7 +5629,7 @@ add_nonlocal_symbols (struct obstack *obstackp,
                                               symbol_name_match_type::FULL,
                                               compare_names);
 
-      ALL_OBJFILE_COMPUNITS (objfile, cu)
+      for (compunit_symtab *cu : objfile_compunits (objfile))
        {
          const struct block *global_block
            = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cu), GLOBAL_BLOCK);
@@ -6391,7 +6390,6 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker,
                                       enum type_code code)
 {
   struct symbol *sym;
-  struct compunit_symtab *s;
   const struct block *b, *surrounding_static_block = 0;
   struct block_iterator iter;
 
@@ -13551,7 +13549,6 @@ ada_add_global_exceptions (compiled_regex *preg,
                           std::vector<ada_exc_info> *exceptions)
 {
   struct objfile *objfile;
-  struct compunit_symtab *s;
 
   /* In Ada, the symbol "search name" is a linkage name, whereas the
      regular expression used to do the matching refers to the natural
index e6ca7ed8aff008adeb33106bd42b1979697a32cf..2a864892ed1323e31796bd96bcd08c3fcf60d8cc 100644 (file)
@@ -1203,7 +1203,6 @@ 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").  */
   {
-    struct compunit_symtab *cu;
     struct symtab *s;
 
     ALL_OBJFILE_FILETABS (objfile, cu, s)
index a5349ed3e3150b151a124892ad1d9d40f4890391..790670256b7f158d8aae5a2fa627ec5ff9880e66 100644 (file)
@@ -1373,7 +1373,6 @@ static void
 add_symbol_overload_list_qualified (const char *func_name,
                                    std::vector<symbol *> *overload_list)
 {
-  struct compunit_symtab *cust;
   const struct block *b, *surrounding_static_block = 0;
 
   /* Look through the partial symtabs for all symbols which begin by
index 0d08bbee9437b09f84ef72a9a7ff6c155ef7b805..964697b7bcbd3f6be276bd500916f1bf06ed0cad 100644 (file)
@@ -1143,8 +1143,6 @@ iterate_over_all_matching_symtabs
 
     for (objfile *objfile : all_objfiles (current_program_space))
       {
-       struct compunit_symtab *cu;
-
        if (objfile->sf)
          objfile->sf->qf->expand_symtabs_matching (objfile,
                                                    NULL,
@@ -1152,7 +1150,7 @@ iterate_over_all_matching_symtabs
                                                    NULL, NULL,
                                                    search_domain);
 
-       ALL_OBJFILE_COMPUNITS (objfile, cu)
+       for (compunit_symtab *cu : objfile_compunits (objfile))
          {
            struct symtab *symtab = COMPUNIT_FILETABS (cu);
 
index 01d04df75bfd22562ad8a45c433083d3e7336aa2..a4241cdca5370447d526168249f17c357625b85f 100644 (file)
@@ -763,7 +763,6 @@ count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr,
                          int *nr_blocks_ptr)
 {
   struct objfile *o;
-  struct compunit_symtab *cu;
   struct symtab *s;
   int nr_symtabs = 0;
   int nr_compunit_symtabs = 0;
index 580dd904276710b4f4b9c5fb8c41d2781825aad1..dbd535b1767e5a0987c579d8cb4f5ca6f346b516 100644 (file)
@@ -84,7 +84,6 @@ void
 mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc)
 {
   struct ui_out *uiout = current_uiout;
-  struct compunit_symtab *cu;
   struct symtab *s;
   struct objfile *objfile;
 
index 5d46e69dc316a3ec63bf84426f5d0b80546a099a..dc94322baf8f36776f8121d3b17a3501ac228ec1 100644 (file)
@@ -788,7 +788,6 @@ objfile_relocate1 (struct objfile *objfile,
 
   /* OK, get all the symtabs.  */
   {
-    struct compunit_symtab *cust;
     struct symtab *s;
 
     ALL_OBJFILE_FILETABS (objfile, cust, s)
@@ -806,41 +805,42 @@ objfile_relocate1 (struct objfile *objfile,
        }
     }
 
-    ALL_OBJFILE_COMPUNITS (objfile, cust)
-    {
-      const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
-      int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust);
-
-      if (BLOCKVECTOR_MAP (bv))
-       addrmap_relocate (BLOCKVECTOR_MAP (bv),
-                         ANOFFSET (delta, block_line_section));
-
-      for (int i = 0; i < BLOCKVECTOR_NBLOCKS (bv); ++i)
-       {
-         struct block *b;
-         struct symbol *sym;
-         struct dict_iterator iter;
-
-         b = BLOCKVECTOR_BLOCK (bv, i);
-         BLOCK_START (b) += ANOFFSET (delta, block_line_section);
-         BLOCK_END (b) += ANOFFSET (delta, block_line_section);
-
-         if (BLOCK_RANGES (b) != nullptr)
-           for (int j = 0; j < BLOCK_NRANGES (b); j++)
+    for (compunit_symtab *cust : objfile_compunits (objfile))
+      {
+       const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
+       int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust);
+
+       if (BLOCKVECTOR_MAP (bv))
+         addrmap_relocate (BLOCKVECTOR_MAP (bv),
+                           ANOFFSET (delta, block_line_section));
+
+       for (int i = 0; i < BLOCKVECTOR_NBLOCKS (bv); ++i)
+         {
+           struct block *b;
+           struct symbol *sym;
+           struct dict_iterator iter;
+
+           b = BLOCKVECTOR_BLOCK (bv, i);
+           BLOCK_START (b) += ANOFFSET (delta, block_line_section);
+           BLOCK_END (b) += ANOFFSET (delta, block_line_section);
+
+           if (BLOCK_RANGES (b) != nullptr)
+             for (int j = 0; j < BLOCK_NRANGES (b); j++)
+               {
+                 BLOCK_RANGE_START (b, j)
+                   += ANOFFSET (delta, block_line_section);
+                 BLOCK_RANGE_END (b, j) += ANOFFSET (delta,
+                                                     block_line_section);
+               }
+
+           /* We only want to iterate over the local symbols, not any
+              symbols in included symtabs.  */
+           ALL_DICT_SYMBOLS (BLOCK_DICT (b), iter, sym)
              {
-               BLOCK_RANGE_START (b, j)
-                 += ANOFFSET (delta, block_line_section);
-               BLOCK_RANGE_END (b, j) += ANOFFSET (delta, block_line_section);
+               relocate_one_symbol (sym, objfile, delta);
              }
-
-         /* We only want to iterate over the local symbols, not any
-            symbols in included symtabs.  */
-         ALL_DICT_SYMBOLS (BLOCK_DICT (b), iter, sym)
-           {
-             relocate_one_symbol (sym, objfile, delta);
-           }
-       }
-    }
+         }
+      }
   }
 
   /* This stores relocated addresses and so must be cleared.  This
index a3b0e9213550ff6db53947dc08a0259f9bf7f8d2..ba6be2dcdd5cd838da061ce3018081bc30e219f3 100644 (file)
@@ -615,13 +615,21 @@ public:
 /* Traverse all symtabs in one objfile.  */
 
 #define ALL_OBJFILE_FILETABS(objfile, cu, s) \
-  ALL_OBJFILE_COMPUNITS (objfile, cu) \
+  for (compunit_symtab *cu : objfile_compunits (objfile)) \
     ALL_COMPUNIT_FILETABS (cu, s)
 
-/* Traverse all compunits in one objfile.  */
+/* A range adapter that makes it possible to iterate over all
+   compunits in one objfile.  */
+
+class objfile_compunits : public next_adapter<struct compunit_symtab>
+{
+public:
 
-#define ALL_OBJFILE_COMPUNITS(objfile, cu) \
-  for ((cu) = (objfile) -> compunit_symtabs; (cu) != NULL; (cu) = (cu) -> next)
+  explicit objfile_compunits (struct objfile *objfile)
+    : next_adapter<struct compunit_symtab> (objfile->compunit_symtabs)
+  {
+  }
+};
 
 /* A range adapter that makes it possible to iterate over all
    minimal symbols of an objfile.  */
@@ -714,7 +722,7 @@ private:
 
 #define ALL_COMPUNITS(objfile, cu)     \
   ALL_OBJFILES (objfile)               \
-    ALL_OBJFILE_COMPUNITS (objfile, cu)
+    for (compunit_symtab *cu : objfile_compunits (objfile))
 
 #define ALL_OBJFILE_OSECTIONS(objfile, osect)  \
   for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
index 74c895c27b8d10bf4a92932aa937517eb4c76ed6..3fc4ad5d2b622a006c95bd8d5247dac2545acd2a 100644 (file)
@@ -239,7 +239,6 @@ void
 select_source_symtab (struct symtab *s)
 {
   struct objfile *ofp;
-  struct compunit_symtab *cu;
 
   if (s)
     {
@@ -350,7 +349,6 @@ show_directories_command (struct ui_file *file, int from_tty,
 void
 forget_cached_source_info_for_objfile (struct objfile *objfile)
 {
-  struct compunit_symtab *cu;
   struct symtab *s;
 
   ALL_OBJFILE_FILETABS (objfile, cu, s)
index 24f9176a8a12c8f7353bf6d399457605eb7f285a..afe9d0457366293da7c82a42967827ee95e51b72 100644 (file)
@@ -82,7 +82,6 @@ void
 print_objfile_statistics (void)
 {
   struct program_space *pspace;
-  struct compunit_symtab *cu;
   struct symtab *s;
   int i, linetables, blockvectors;
 
@@ -108,15 +107,15 @@ print_objfile_statistics (void)
                         OBJSTAT (objfile, n_types));
       if (objfile->sf)
        objfile->sf->qf->print_stats (objfile);
-      i = linetables = blockvectors = 0;
+      i = linetables = 0;
       ALL_OBJFILE_FILETABS (objfile, cu, s)
        {
          i++;
          if (SYMTAB_LINETABLE (s) != NULL)
            linetables++;
        }
-      ALL_OBJFILE_COMPUNITS (objfile, cu)
-       blockvectors++;
+      blockvectors = std::distance (objfile_compunits (objfile).begin (),
+                                   objfile_compunits (objfile).end ());
       printf_filtered (_("  Number of symbol tables: %d\n"), i);
       printf_filtered (_("  Number of symbol tables with line tables: %d\n"),
                       linetables);
@@ -145,7 +144,6 @@ print_objfile_statistics (void)
 static void
 dump_objfile (struct objfile *objfile)
 {
-  struct compunit_symtab *cust;
   struct symtab *symtab;
 
   printf_filtered ("\nObject file %s:  ", objfile_name (objfile));
@@ -469,7 +467,6 @@ maintenance_print_symbols (const char *args, int from_tty)
     }
   else
     {
-      struct compunit_symtab *cu;
       struct symtab *s;
       int found = 0;
 
@@ -775,14 +772,13 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
   ALL_PSPACES (pspace)
     for (objfile *objfile : all_objfiles (pspace))
       {
-       struct compunit_symtab *cust;
        struct symtab *symtab;
 
        /* We don't want to print anything for this objfile until we
           actually find a symtab whose name matches.  */
        int printed_objfile_start = 0;
 
-       ALL_OBJFILE_COMPUNITS (objfile, cust)
+       for (compunit_symtab *cust : objfile_compunits (objfile))
          {
            int printed_compunit_symtab_start = 0;
 
@@ -863,13 +859,11 @@ maintenance_check_symtabs (const char *ignore, int from_tty)
   ALL_PSPACES (pspace)
     for (objfile *objfile : all_objfiles (pspace))
       {
-       struct compunit_symtab *cust;
-
        /* We don't want to print anything for this objfile until we
           actually find something worth printing.  */
        int printed_objfile_start = 0;
 
-       ALL_OBJFILE_COMPUNITS (objfile, cust)
+       for (compunit_symtab *cust : objfile_compunits (objfile))
          {
            int found_something = 0;
            struct symtab *symtab = compunit_primary_filetab (cust);
@@ -1032,10 +1026,9 @@ maintenance_info_line_tables (const char *regexp, int from_tty)
   ALL_PSPACES (pspace)
     for (objfile *objfile : all_objfiles (pspace))
       {
-       struct compunit_symtab *cust;
        struct symtab *symtab;
 
-       ALL_OBJFILE_COMPUNITS (objfile, cust)
+       for (compunit_symtab *cust : objfile_compunits (objfile))
          {
            ALL_COMPUNIT_FILETABS (cust, symtab)
              {
index 8bd91bc84797c41866f7920b2155c4e53a381edd..0cd51192f814b4a1d13aa910dda4afb43adf3bda 100644 (file)
@@ -2167,7 +2167,6 @@ struct objfile *
 lookup_objfile_from_block (const struct block *block)
 {
   struct objfile *obj;
-  struct compunit_symtab *cust;
 
   if (block == NULL)
     return NULL;
@@ -2255,8 +2254,6 @@ static struct block_symbol
 lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index,
                                  const char *name, const domain_enum domain)
 {
-  struct compunit_symtab *cust;
-
   gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
 
   if (symbol_lookup_debug > 1)
@@ -2269,7 +2266,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index,
                          name, domain_name (domain));
     }
 
-  ALL_OBJFILE_COMPUNITS (objfile, cust)
+  for (compunit_symtab *cust : objfile_compunits (objfile))
     {
       const struct blockvector *bv;
       const struct block *block;
@@ -2763,12 +2760,11 @@ static struct type *
 basic_lookup_transparent_type_1 (struct objfile *objfile, int block_index,
                                 const char *name)
 {
-  const struct compunit_symtab *cust;
   const struct blockvector *bv;
   const struct block *block;
   const struct symbol *sym;
 
-  ALL_OBJFILE_COMPUNITS (objfile, cust)
+  for (compunit_symtab *cust : objfile_compunits (objfile))
     {
       bv = COMPUNIT_BLOCKVECTOR (cust);
       block = BLOCKVECTOR_BLOCK (bv, block_index);
@@ -2874,7 +2870,6 @@ iterate_over_symbols (const struct block *block,
 struct compunit_symtab *
 find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
 {
-  struct compunit_symtab *cust;
   struct compunit_symtab *best_cust = NULL;
   struct objfile *obj_file;
   CORE_ADDR distance = 0;
@@ -3349,7 +3344,6 @@ find_line_symtab (struct symtab *symtab, int line,
          BEST_INDEX and BEST_LINETABLE identify the item for it.  */
       int best;
 
-      struct compunit_symtab *cu;
       struct symtab *s;
 
       if (best_index >= 0)
@@ -4185,7 +4179,6 @@ output_partial_symbol_filename (const char *filename, const char *fullname,
 static void
 info_sources_command (const char *ignore, int from_tty)
 {
-  struct compunit_symtab *cu;
   struct symtab *s;
   struct objfile *objfile;
   struct output_source_filename_data data;
@@ -4338,7 +4331,6 @@ search_symbols (const char *regexp, enum search_domain kind,
                const char *t_regexp,
                int nfiles, const char *files[])
 {
-  struct compunit_symtab *cust;
   const struct blockvector *bv;
   struct block *b;
   int i = 0;
@@ -5202,7 +5194,6 @@ default_collect_symbol_completion_matches_break_on
      won't be that many.  */
 
   struct symbol *sym;
-  struct compunit_symtab *cust;
   const struct block *b;
   const struct block *surrounding_static_block, *surrounding_global_block;
   struct block_iterator iter;
@@ -5588,7 +5579,6 @@ maybe_add_partial_symtab_filename (const char *filename, const char *fullname,
 completion_list
 make_source_files_completion_list (const char *text, const char *word)
 {
-  struct compunit_symtab *cu;
   struct symtab *s;
   struct objfile *objfile;
   size_t text_len = strlen (text);