current TU; imports start at 1. */
static GTY(()) vec<module_state *, va_gc> *modules;
+/* Get the module state for the current TU's module. */
+
+static module_state *
+this_module() {
+ return (*modules)[0];
+}
+
/* Hash of module state, findable by {name, parent}. */
static GTY(()) hash_table<module_state_hash> *modules_hash;
{
if (index > ~(~0u >> 1))
/* This is an index for an exported entity. */
- return (*modules)[0];
+ return this_module ();
/* Do not include the current TU (not an off-by-one error). */
unsigned pos = 1;
if (streaming_p () && dump (dumper::TREE))
{
char const *kind = "import";
- module_state *from = (*modules)[0];
+ module_state *from = this_module ();
if (dep->is_import ())
/* Rediscover the unremapped index. */
from = import_entity_module (import_entity_index (decl));
if (partition)
{
if (!parent)
- parent = get_primary ((*modules)[0]);
+ parent = get_primary (this_module ());
if (!parent->is_partition () && !parent->flatname)
parent->set_flatname ();
bool
module_state::check_not_purview (location_t from)
{
- module_state *imp = (*modules)[0];
+ module_state *imp = this_module ();
if (imp && !imp->name)
imp = imp->parent;
if (imp == this)
module as this TU. */
if (imp && imp->is_partition () &&
(!named_module_p ()
- || (get_primary ((*modules)[0]) != get_primary (imp))))
+ || (get_primary (this_module ()) != get_primary (imp))))
imp = NULL;
if (!imp)
bool
module_state::read_using_directives (unsigned num)
{
- if (!bitmap_bit_p ((*modules)[0]->imports, mod))
+ if (!bitmap_bit_p (this_module ()->imports, mod))
{
dump () && dump ("Ignoring using-directives because module %M "
"is not visible in this TU", this);
/* Determine the module's number. */
gcc_checking_assert (mod == MODULE_UNKNOWN);
- gcc_checking_assert (this != (*modules)[0]);
+ gcc_checking_assert (this != this_module ());
{
/* Allocate space in the entities array now -- that array must be
bitmap
get_import_bitmap ()
{
- return (*modules)[0]->imports;
+ return this_module ()->imports;
}
/* Return the visible imports and path of instantiation for an
// FIXME: Should we be checking this in more places on the scope chain?
return true;
- module_state *old_mod = (*modules)[0];
+ module_state *old_mod = this_module ();
module_state *new_mod = old_mod;
tree old_origin = get_originating_module_decl (decl);
if (!import->do_import (reader, true))
gcc_unreachable ();
- (*modules)[0]->set_import (import, import->exported_p);
+ this_module ()->set_import (import, import->exported_p);
if (import->loadedness < ML_LANGUAGE)
{
{
gcc_assert (global_namespace == current_scope ());
- module_state *current = (*modules)[0];
+ module_state *current = this_module ();
if (module_purview_p () || module->loadedness > ML_CONFIG)
{
auto_diagnostic_group d;
return;
}
- gcc_checking_assert (module->module_p);
+ gcc_checking_assert (module->is_module ());
gcc_checking_assert (module->is_direct () && module->has_location ());
/* Yer a module, 'arry. */
gcc_checking_assert (module->is_direct ());
if (!module->filename && !module->visited_p)
{
- bool export_p = (module->module_p
- && (module->is_partition () || module->exported_p));
+ bool export_p = (module->is_module ()
+ && (module->is_partition ()
+ || module->is_exported ()));
Cody::Flags flags = Cody::Flags::None;
if (flag_preprocess_only
for (unsigned ix = 0; ix != pending_imports->length (); ix++)
{
auto *import = (*pending_imports)[ix];
- if (!(import->module_p
- && (import->is_partition () || import->exported_p))
+ if (!(import->is_module ()
+ && (import->is_partition () || import->is_exported ()))
&& import->loadedness == ML_NONE
&& (import->is_header () || !flag_preprocess_only))
{
if (header_module_p ())
module_kind &= ~MK_EXPORTING;
- if (!modules || !(*modules)[0]->name)
+ if (!modules || !this_module ()->name)
{
if (flag_module_only)
warning (0, "%<-fmodule-only%> used for non-interface");
/* We write to a tmpname, and then atomically rename. */
char *cmi_name = NULL;
char *tmp_name = NULL;
- module_state *state = (*modules)[0];
+ module_state *state = this_module ();
unsigned n = dump.push (state);
state->announce ("creating");
{
timevar_start (TV_MODULE_EXPORT);
- module_state *state = (*modules)[0];
+ module_state *state = this_module ();
unsigned n = dump.push (state);
state->announce ("finishing");