Commit 98c28dd4 by Nathan Sidwell Committed by Nathan Sidwell

Kill IDENTIFIER_NAMESPACE_BINDINGS

	Kill IDENTIFIER_NAMESPACE_BINDINGS
	* cp-tree.h (lang_identifier): Delete namespace_bindings.
	(IDENTIFIER_NAMESPACE_BINDINGS): Delete.
	(lang_decl_ns): Add bindings.
	(DECL_NAMESPACE_BINDINGS): New.
	* lex.c (retrofit_lang_decl): Create namespace hash table.
	* name-lookup.c (find_namespace_slot): Change to use hash-map.
	* ptree.c (cxx_print_binding): Delete.
	(cxx_print_identifier): Remove NAMESPACE_BINDING printing.

From-SVN: r248694
parent 5256a7f5
2017-05-30 Nathan Sidwell <nathan@acm.org> 2017-05-30 Nathan Sidwell <nathan@acm.org>
Kill IDENTIFIER_NAMESPACE_BINDINGS
* cp-tree.h (lang_identifier): Delete namespace_bindings.
(IDENTIFIER_NAMESPACE_BINDINGS): Delete.
(lang_decl_ns): Add bindings.
(DECL_NAMESPACE_BINDINGS): New.
* lex.c (retrofit_lang_decl): Create namespace hash table.
* name-lookup.c (find_namespace_slot): Change to use hash-map.
* ptree.c (cxx_print_binding): Delete.
(cxx_print_identifier): Remove NAMESPACE_BINDING printing.
* cp-tree.def (OVERLOAD): Fix comment. * cp-tree.def (OVERLOAD): Fix comment.
* cp-tree.h: Fix comments and whitespace. * cp-tree.h: Fix comments and whitespace.
* error.c (dump_decl): Use pp_cxx_colon_colon, ovl_scope. * error.c (dump_decl): Use pp_cxx_colon_colon, ovl_scope.
......
...@@ -535,7 +535,6 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX]; ...@@ -535,7 +535,6 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
struct GTY(()) lang_identifier { struct GTY(()) lang_identifier {
struct c_common_identifier c_common; struct c_common_identifier c_common;
cxx_binding *namespace_bindings;
cxx_binding *bindings; cxx_binding *bindings;
tree class_template_info; tree class_template_info;
tree label_value; tree label_value;
...@@ -965,8 +964,6 @@ enum GTY(()) abstract_class_use { ...@@ -965,8 +964,6 @@ enum GTY(()) abstract_class_use {
/* Macros for access to language-specific slots in an identifier. */ /* Macros for access to language-specific slots in an identifier. */
#define IDENTIFIER_NAMESPACE_BINDINGS(NODE) \
(LANG_IDENTIFIER_CAST (NODE)->namespace_bindings)
#define IDENTIFIER_TEMPLATE(NODE) \ #define IDENTIFIER_TEMPLATE(NODE) \
(LANG_IDENTIFIER_CAST (NODE)->class_template_info) (LANG_IDENTIFIER_CAST (NODE)->class_template_info)
...@@ -2552,6 +2549,9 @@ struct GTY(()) lang_decl_ns { ...@@ -2552,6 +2549,9 @@ struct GTY(()) lang_decl_ns {
because of PCH. */ because of PCH. */
vec<tree, va_gc> *usings; vec<tree, va_gc> *usings;
vec<tree, va_gc> *inlinees; vec<tree, va_gc> *inlinees;
/* Map from IDENTIFIER nodes to DECLS. */
hash_map<lang_identifier *, tree> *bindings;
}; };
/* DECL_LANG_SPECIFIC for parameters. */ /* DECL_LANG_SPECIFIC for parameters. */
...@@ -3146,6 +3146,10 @@ struct GTY(()) lang_decl { ...@@ -3146,6 +3146,10 @@ struct GTY(()) lang_decl {
#define DECL_NAMESPACE_INLINEES(NODE) \ #define DECL_NAMESPACE_INLINEES(NODE) \
(LANG_DECL_NS_CHECK (NODE)->inlinees) (LANG_DECL_NS_CHECK (NODE)->inlinees)
/* Pointer to hash_map from IDENTIFIERS to DECLS */
#define DECL_NAMESPACE_BINDINGS(NODE) \
(LANG_DECL_NS_CHECK (NODE)->bindings)
/* In a NAMESPACE_DECL, points to the original namespace if this is /* In a NAMESPACE_DECL, points to the original namespace if this is
a namespace alias. */ a namespace alias. */
#define DECL_NAMESPACE_ALIAS(NODE) \ #define DECL_NAMESPACE_ALIAS(NODE) \
......
...@@ -566,8 +566,12 @@ retrofit_lang_decl (tree t, int sel) ...@@ -566,8 +566,12 @@ retrofit_lang_decl (tree t, int sel)
memcpy (ld, DECL_LANG_SPECIFIC (t), oldsize); memcpy (ld, DECL_LANG_SPECIFIC (t), oldsize);
ld->u.base.selector = sel; ld->u.base.selector = sel;
DECL_LANG_SPECIFIC (t) = ld; DECL_LANG_SPECIFIC (t) = ld;
if (sel == 2)
/* Who'd create a namespace, only to put nothing in it? */
ld->u.ns.bindings = hash_map<lang_identifier *, tree>::create_ggc (499);
if (current_lang_name == lang_name_cplusplus if (current_lang_name == lang_name_cplusplus
|| decl_linkage (t) == lk_none) || decl_linkage (t) == lk_none)
SET_DECL_LANGUAGE (t, lang_cplusplus); SET_DECL_LANGUAGE (t, lang_cplusplus);
......
...@@ -86,25 +86,18 @@ create_local_binding (cp_binding_level *level, tree name) ...@@ -86,25 +86,18 @@ create_local_binding (cp_binding_level *level, tree name)
static tree * static tree *
find_namespace_slot (tree ns, tree name, bool create_p = false) find_namespace_slot (tree ns, tree name, bool create_p = false)
{ {
cp_binding_level *level = NAMESPACE_LEVEL (ns); tree *slot;
cxx_binding *binding = IDENTIFIER_NAMESPACE_BINDINGS (name);
for (;binding; binding = binding->previous)
if (binding->scope == level)
return &binding->value;
if (create_p) if (create_p)
{ {
binding = cxx_binding_make (NULL, NULL); bool existed;
binding->previous = IDENTIFIER_NAMESPACE_BINDINGS (name); slot = &DECL_NAMESPACE_BINDINGS (ns)->get_or_insert (name, &existed);
binding->scope = level; if (!existed)
binding->is_local = false; *slot = NULL_TREE;
binding->value_is_inherited = false;
IDENTIFIER_NAMESPACE_BINDINGS (name) = binding;
return &binding->value;
} }
else
return NULL; slot = DECL_NAMESPACE_BINDINGS (ns)->get (name);
return slot;
} }
static tree static tree
......
...@@ -171,14 +171,6 @@ cxx_print_type (FILE *file, tree node, int indent) ...@@ -171,14 +171,6 @@ cxx_print_type (FILE *file, tree node, int indent)
} }
} }
static void
cxx_print_binding (FILE *stream, cxx_binding *binding, const char *prefix)
{
fprintf (stream, "%s <%p>",
prefix, (void *) binding);
}
void void
cxx_print_identifier (FILE *file, tree node, int indent) cxx_print_identifier (FILE *file, tree node, int indent)
{ {
...@@ -186,12 +178,7 @@ cxx_print_identifier (FILE *file, tree node, int indent) ...@@ -186,12 +178,7 @@ cxx_print_identifier (FILE *file, tree node, int indent)
fprintf (file, " "); fprintf (file, " ");
else else
indent_to (file, indent + 4); indent_to (file, indent + 4);
cxx_print_binding (file, IDENTIFIER_NAMESPACE_BINDINGS (node), "bindings"); fprintf (file, "local bindings <%p>", (void *) IDENTIFIER_BINDING (node));
if (indent == 0)
fprintf (file, " ");
else
indent_to (file, indent + 4);
cxx_print_binding (file, IDENTIFIER_BINDING (node), "local bindings");
print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4); print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4);
print_node (file, "template", IDENTIFIER_TEMPLATE (node), indent + 4); print_node (file, "template", IDENTIFIER_TEMPLATE (node), indent + 4);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment