]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Hoist language-finding in expand_symtabs_matching
authorTom Tromey <tom@tromey.com>
Sat, 8 Feb 2025 02:14:35 +0000 (19:14 -0700)
committerTom Tromey <tom@tromey.com>
Thu, 20 Feb 2025 01:11:24 +0000 (18:11 -0700)
Right now, cooked_index_functions::expand_symtabs_matching computes
the language for each component of a split name, using the language of
the corresponding entry.

Instead, I think that we want to do all the comparisons using the
final entry's language.  I don't think there's a way to trigger bad
behavior here right now, but with another series I'm working on, we
end up with some entries whose language can't reliably be determined;
and in this case using the final entry's language avoids issues.

I suspect we could also dispense with the per-segment name-matcher
lookup as well.

gdb/dwarf2/read.c

index 821f761558c945b9fa0a4093c668cf3ad78cacef..5ff80262d0303f83fc117d03fed402a4b89b28a9 100644 (file)
@@ -16130,6 +16130,7 @@ cooked_index_functions::expand_symtabs_matching
          bool found = true;
 
          const cooked_index_entry *parent = entry->get_parent ();
+         const language_defn *lang_def = language_def (entry->lang);
          for (int i = name_vec.size () - 1; i > 0; --i)
            {
              /* If we ran out of entries, or if this segment doesn't
@@ -16141,7 +16142,6 @@ cooked_index_functions::expand_symtabs_matching
                }
              if (parent->lang != language_unknown)
                {
-                 const language_defn *lang_def = language_def (parent->lang);
                  symbol_name_matcher_ftype *name_matcher
                    = lang_def->get_symbol_name_matcher
                      (segment_lookup_names[i-1]);
@@ -16172,7 +16172,6 @@ cooked_index_functions::expand_symtabs_matching
 
                  if (entry->lang != language_unknown)
                    {
-                     const language_defn *lang_def = language_def (entry->lang);
                      symbol_name_matcher_ftype *name_matcher
                        = lang_def->get_symbol_name_matcher
                          (segment_lookup_names.back ());