/* Push a context block. VALU is the starting PC address of this
context. */
-context_stack &
+void
buildsym_compunit::push_context (CORE_ADDR valu)
{
- context_stack &ctx
- = m_context_stack.emplace_back (std::move (m_local_symbols),
- m_local_using_directives,
- m_pending_blocks, valu);
-
+ m_context_stack.emplace_back (std::move (m_local_symbols),
+ m_local_using_directives,
+ m_pending_blocks, valu);
m_local_using_directives = nullptr;
-
- return ctx;
}
/* See buildsym.h. */
return m_context_stack.empty ();
}
- struct context_stack *get_current_context_stack ()
+ /* Return true if the lexical context currently being constructed
+ has a symbol, false otherwise. */
+ bool current_context_has_function () const
{
- if (m_context_stack.empty ())
- return nullptr;
- return &m_context_stack.back ();
+ return (!m_context_stack.empty ()
+ && m_context_stack.back ().name != nullptr);
+ }
+
+ /* Set the symbol on the lexical context currently being
+ constructed. */
+ void set_current_context_function (symbol *fun)
+ {
+ gdb_assert (!m_context_stack.empty ());
+ gdb_assert (m_context_stack.back ().name == nullptr);
+ gdb_assert (fun != nullptr);
+ m_context_stack.back ().name = fun;
}
struct subfile *get_current_subfile ()
m_producer = producer;
}
- context_stack &push_context (CORE_ADDR valu);
+ void push_context (CORE_ADDR valu);
/* Pop a context and create the corresponding block. Returns the
block. END_ADDR is the final address of the block. STATIC_LINK,
}
}
- gdb_assert (cu->get_builder () != nullptr);
- context_stack &ctx = cu->get_builder ()->push_context (lowpc);
+ buildsym_compunit *builder = cu->get_builder ();
+ gdb_assert (builder != nullptr);
+ builder->push_context (lowpc);
symbol *func_sym = new_symbol (die, read_type_die (die, cu), cu, templ_func);
- ctx.name = func_sym;
+ builder->set_current_context_function (func_sym);
if (dwarf2_func_is_main_p (die, cu))
set_objfile_main_name (objfile, func_sym->linkage_name (),
scoped_restore save_scope
= make_scoped_restore (&cu->list_in_scope,
- &cu->get_builder ()->get_local_symbols ());
+ &builder->get_local_symbols ());
for (die_info *child_die : die->children ())
{
}
}
- block *block = cu->get_builder ()->pop_context (highpc, static_link);
+ block *block = builder->pop_context (highpc, static_link);
/* For C++, set the block's scope. */
if ((cu->lang () == language_cplus
pretend it's a local variable in that case so that the user can
still see it. */
sym->set_domain (VAR_DOMAIN);
- struct context_stack *curr
- = cu->get_builder ()->get_current_context_stack ();
- if (curr != nullptr && curr->name != nullptr)
+ if (cu->get_builder ()->current_context_has_function ())
sym->set_is_argument (true);
attr = dwarf2_attr (die, DW_AT_location, cu);
if (attr != nullptr)