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.h: Fix comments and whitespace.
* error.c (dump_decl): Use pp_cxx_colon_colon, ovl_scope.
struct GTY(()) lang_identifier {
struct c_common_identifier c_common;
- cxx_binding *namespace_bindings;
cxx_binding *bindings;
tree class_template_info;
tree label_value;
/* 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) \
(LANG_IDENTIFIER_CAST (NODE)->class_template_info)
because of PCH. */
vec<tree, va_gc> *usings;
vec<tree, va_gc> *inlinees;
+
+ /* Map from IDENTIFIER nodes to DECLS. */
+ hash_map<lang_identifier *, tree> *bindings;
};
/* DECL_LANG_SPECIFIC for parameters. */
#define DECL_NAMESPACE_INLINEES(NODE) \
(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
a namespace alias. */
#define DECL_NAMESPACE_ALIAS(NODE) \
memcpy (ld, DECL_LANG_SPECIFIC (t), oldsize);
ld->u.base.selector = sel;
-
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
|| decl_linkage (t) == lk_none)
SET_DECL_LANGUAGE (t, lang_cplusplus);
static tree *
find_namespace_slot (tree ns, tree name, bool create_p = false)
{
- cp_binding_level *level = NAMESPACE_LEVEL (ns);
- cxx_binding *binding = IDENTIFIER_NAMESPACE_BINDINGS (name);
-
- for (;binding; binding = binding->previous)
- if (binding->scope == level)
- return &binding->value;
+ tree *slot;
if (create_p)
{
- binding = cxx_binding_make (NULL, NULL);
- binding->previous = IDENTIFIER_NAMESPACE_BINDINGS (name);
- binding->scope = level;
- binding->is_local = false;
- binding->value_is_inherited = false;
- IDENTIFIER_NAMESPACE_BINDINGS (name) = binding;
- return &binding->value;
+ bool existed;
+ slot = &DECL_NAMESPACE_BINDINGS (ns)->get_or_insert (name, &existed);
+ if (!existed)
+ *slot = NULL_TREE;
}
-
- return NULL;
+ else
+ slot = DECL_NAMESPACE_BINDINGS (ns)->get (name);
+ return slot;
}
static tree
}
}
-
-static void
-cxx_print_binding (FILE *stream, cxx_binding *binding, const char *prefix)
-{
- fprintf (stream, "%s <%p>",
- prefix, (void *) binding);
-}
-
void
cxx_print_identifier (FILE *file, tree node, int indent)
{
fprintf (file, " ");
else
indent_to (file, indent + 4);
- cxx_print_binding (file, IDENTIFIER_NAMESPACE_BINDINGS (node), "bindings");
- if (indent == 0)
- fprintf (file, " ");
- else
- indent_to (file, indent + 4);
- cxx_print_binding (file, IDENTIFIER_BINDING (node), "local bindings");
+ fprintf (file, "local bindings <%p>", (void *) IDENTIFIER_BINDING (node));
print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4);
print_node (file, "template", IDENTIFIER_TEMPLATE (node), indent + 4);
}