c++: Name lookup for modules
This augments the name lookup with knowledge about the BINDING_VECTOR. That holds per-module namespace bindings, and we need to collect the bindings in visible imports when we do lookup. We also need to do some checking when we're pushing a new decl to check we're not overriding an existing visible binding in some way. To deal with the Global Module and Module Partitions, we reserve 1 or 2 slots inthe BINDING_VECTOR to record those entities that may legitimately appear in more than one module. As mentioned before, the BINDING_VECTOR is created lazily, when imported bindings appear. The current TUs decls then appear on slot zero. gcc/cp/ * cp-tree.h (visible_instantiation_path): Renamed. * module.cc (get_originating_module_decl, lazy_load_binding) (lazy_load_members, visible_instantiation_path): Stubs. * name-lookup.c (STAT_TYPE_VISIBLE_P, STAT_VISIBLE): New. (search_imported_binding_slot, init_global_partition) (get_fixed_binding_slot): New. (name_lookup::process_module_binding): New. (name_lookup::search_namespace_only): Search BINDING_VECTOR. (name_lookup::adl_namespace_fns): Likewise. (name_lookip::search_adl): Search visible instantiation path. (maybe_lazily_declare): Maybe lazy load members. (implicitly_exporT_namespace): New. (maybe_record_mergeable_decl): New. (check_module_override): New. (do_pushdecl): Deal with BINDING_VECTOR, check override. (add_mergeable_namespace_entity): New. (get_namespace_binding): Deal with BINDING_VECTOR. (do_namespace_alias): Call set_originating_module. (lookup_elaborated_type_1): Deal with BINDING_VECTOR. (do_pushtag): Call set_originating_module. (reuse_namespace): New. (make_namespace_finish): Add FROM_IMPORT parm. (push_namespace): Deal with BINDING_VECTOR & namespace reuse. (maybe_save_operator_binding): Save when module CMI in play. * name-lookup.h (add_mergeable_namespace_entity): Declare.
This commit is contained in:
parent
afc14c8d0a
commit
c0979d8f22
@ -6993,7 +6993,7 @@ extern void maybe_check_all_macros (cpp_reader *);
|
|||||||
extern void finish_module_processing (cpp_reader *);
|
extern void finish_module_processing (cpp_reader *);
|
||||||
extern char const *module_name (unsigned, bool header_ok);
|
extern char const *module_name (unsigned, bool header_ok);
|
||||||
extern bitmap get_import_bitmap ();
|
extern bitmap get_import_bitmap ();
|
||||||
extern bitmap module_visible_instantiation_path (bitmap *);
|
extern bitmap visible_instantiation_path (bitmap *);
|
||||||
extern void module_begin_main_file (cpp_reader *, line_maps *,
|
extern void module_begin_main_file (cpp_reader *, line_maps *,
|
||||||
const line_map_ordinary *);
|
const line_map_ordinary *);
|
||||||
extern void module_preprocess_options (cpp_reader *);
|
extern void module_preprocess_options (cpp_reader *);
|
||||||
|
@ -135,11 +135,33 @@ set_defining_module (tree)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tree
|
||||||
|
get_originating_module_decl (tree decl)
|
||||||
|
{
|
||||||
|
return decl;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
set_originating_module (tree, bool)
|
set_originating_module (tree, bool)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
lazy_load_binding (unsigned, tree, tree, binding_slot *)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
lazy_load_members (tree)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bitmap
|
||||||
|
visible_instantiation_path (bitmap *)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
import_module (module_state *, location_t, bool, tree, cpp_reader *)
|
import_module (module_state *, location_t, bool, tree, cpp_reader *)
|
||||||
{
|
{
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -480,4 +480,7 @@ extern void maybe_save_operator_binding (tree);
|
|||||||
extern void push_operator_bindings (void);
|
extern void push_operator_bindings (void);
|
||||||
extern void discard_operator_bindings (tree);
|
extern void discard_operator_bindings (tree);
|
||||||
|
|
||||||
|
/* Lower level interface for modules. */
|
||||||
|
extern void add_mergeable_namespace_entity (tree *slot, tree decl);
|
||||||
|
|
||||||
#endif /* GCC_CP_NAME_LOOKUP_H */
|
#endif /* GCC_CP_NAME_LOOKUP_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user