symtab->language = subfile->language;
}
- /* Make sure the symtab of main_subfile is the first in its list. */
- {
- struct symtab *main_symtab, *prev_symtab;
-
- main_symtab = m_main_subfile->symtab;
- prev_symtab = NULL;
- for (symtab *symtab : compunit_filetabs (cu))
- {
- if (symtab == main_symtab)
- {
- if (prev_symtab != NULL)
- {
- prev_symtab->next = main_symtab->next;
- main_symtab->next = COMPUNIT_FILETABS (cu);
- COMPUNIT_FILETABS (cu) = main_symtab;
- }
- break;
- }
- prev_symtab = symtab;
- }
- gdb_assert (main_symtab == COMPUNIT_FILETABS (cu));
- }
+ /* Make sure the filetab of main_subfile is the primary filetab of the CU. */
+ cu->set_primary_filetab (m_main_subfile->symtab);
/* Fill out the compunit symtab. */
/* See symtab.h. */
+void
+compunit_symtab::set_primary_filetab (symtab *primary_filetab)
+{
+ symtab *prev_filetab = nullptr;
+
+ /* Move PRIMARY_FILETAB to the head of the filetab list. */
+ for (symtab *filetab : compunit_filetabs (this))
+ {
+ if (filetab == primary_filetab)
+ {
+ if (prev_filetab != nullptr)
+ {
+ prev_filetab->next = primary_filetab->next;
+ primary_filetab->next = this->filetabs;
+ this->filetabs = primary_filetab;
+ }
+
+ break;
+ }
+
+ prev_filetab = filetab;
+ }
+
+ gdb_assert (primary_filetab == this->filetabs);
+}
+
+/* See symtab.h. */
+
struct symtab *
compunit_symtab::primary_filetab () const
{
}
}
+ /* Make PRIMARY_FILETAB the primary filetab of this compunit symtab.
+
+ PRIMARY_FILETAB must already be a filetab of this compunit symtab. */
+
+ void set_primary_filetab (symtab *primary_filetab);
+
/* Return the primary filetab of the compunit. */
symtab *primary_filetab () const;