Hoist language-finding in expand_symtabs_matching
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.
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 821f761..5ff8026 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -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 ());