Commit 89b578be by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (saved_scope): Remove x_previous_class_type and x_previous_class_values...

	* cp-tree.h (saved_scope): Remove x_previous_class_type and
	x_previous_class_values; add x_previous_class_level.
	(previous_class_type): Remove.
	(previous_class_values): Remove.
	(previous_class_level): New macro.
	* class.c (pushclass): Restore the identifier cache more
	expeditiously.
	(invalidate_class_lookup_cache): Use vector for class_shadowed and
	previous_class_values.
	* decl.c (poplevel): Likewise.
	* name-lookup.c (cxx_binding_init): New function.
	(cxx_binding_make): Use it.
	(push_binding): For a binding in a class level, use a vector of
	cp_class_binding nodes.
	(push_binding_level): New function.
	(begin_scope): Use it.
	(leave_scope): Do not put class binding levels on the free list.
	(print_binding_level): Adjust for the fact that class_shadowed is
	a vector.
	(poplevel_class): Likewise.
	(clear_identifier_class_values): Likewise.
	(push_class_level_binding): Likewise.
	(set_class_shadows): Remove.
	(store_binding): New function.
	(store_class_bindings): New function.
	(push_to_top_level): Use store_class_bindings as appropriate.
	(pop_from_top_level): Use previous_class_level, not
	previous_class_type.
	* name-lookup.h (cp_class_binding): New type.
	(cp_binding_level): Use a vector object for class_shadowed.
	(push_binding_level): Declare.
	(set_class_shadows): Remove.

From-SVN: r84259
parent beed8fc0
2004-07-07 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (saved_scope): Remove x_previous_class_type and
x_previous_class_values; add x_previous_class_level.
(previous_class_type): Remove.
(previous_class_values): Remove.
(previous_class_level): New macro.
* class.c (pushclass): Restore the identifier cache more
expeditiously.
(invalidate_class_lookup_cache): Use vector for class_shadowed and
previous_class_values.
* decl.c (poplevel): Likewise.
* name-lookup.c (cxx_binding_init): New function.
(cxx_binding_make): Use it.
(push_binding): For a binding in a class level, use a vector of
cp_class_binding nodes.
(push_binding_level): New function.
(begin_scope): Use it.
(leave_scope): Do not put class binding levels on the free list.
(print_binding_level): Adjust for the fact that class_shadowed is
a vector.
(poplevel_class): Likewise.
(clear_identifier_class_values): Likewise.
(push_class_level_binding): Likewise.
(set_class_shadows): Remove.
(store_binding): New function.
(store_class_bindings): New function.
(push_to_top_level): Use store_class_bindings as appropriate.
(pop_from_top_level): Use previous_class_level, not
previous_class_type.
* name-lookup.h (cp_class_binding): New type.
(cp_binding_level): Use a vector object for class_shadowed.
(push_binding_level): Declare.
(set_class_shadows): Remove.
2004-07-07 Andrew Pinski <apinski@apple.com>
* class.c (instantiate_type): BUFFER_REF is dead.
......
......@@ -5486,9 +5486,8 @@ pushclass (tree type)
? access_private_node
: access_public_node);
if (previous_class_type != NULL_TREE
&& (type != previous_class_type
|| !COMPLETE_TYPE_P (previous_class_type))
if (previous_class_level
&& type != previous_class_level->this_entity
&& current_class_depth == 1)
{
/* Forcibly remove any old class remnants. */
......@@ -5500,10 +5499,11 @@ pushclass (tree type)
if (current_class_depth > 1)
clear_identifier_class_values ();
pushlevel_class ();
if (type != previous_class_type || current_class_depth > 1)
if (!previous_class_level
|| type != previous_class_level->this_entity
|| current_class_depth > 1)
{
pushlevel_class ();
push_class_decls (type);
if (CLASSTYPE_TEMPLATE_INFO (type) && !CLASSTYPE_USE_TEMPLATE (type))
{
......@@ -5520,22 +5520,33 @@ pushclass (tree type)
}
else
{
tree item;
cp_class_binding *cb;
size_t i;
/* We are re-entering the same class we just left, so we don't
have to search the whole inheritance matrix to find all the
decls to bind again. Instead, we install the cached
class_shadowed list, and walk through it binding names and
setting up IDENTIFIER_TYPE_VALUEs. */
set_class_shadows (previous_class_values);
for (item = previous_class_values; item; item = TREE_CHAIN (item))
push_binding_level (previous_class_level);
class_binding_level = previous_class_level;
for (i = 0;
(cb = VEC_iterate (cp_class_binding,
previous_class_level->class_shadowed,
i));
++i)
{
tree id = TREE_PURPOSE (item);
tree decl = TREE_TYPE (item);
tree id;
tree type_decl;
push_class_binding (id, decl);
if (TREE_CODE (decl) == TYPE_DECL)
set_identifier_type_value (id, decl);
id = cb->identifier;
cb->base.previous = IDENTIFIER_BINDING (id);
IDENTIFIER_BINDING (id) = &cb->base;
type_decl = cb->base.value;
if (!type_decl || TREE_CODE (type_decl) != TYPE_DECL)
type_decl = cb->base.type;
if (type_decl && TREE_CODE (type_decl) == TYPE_DECL)
set_identifier_type_value (id, type_decl);
}
unuse_fields (type);
}
......@@ -5551,14 +5562,17 @@ pushclass (tree type)
void
invalidate_class_lookup_cache (void)
{
tree t;
size_t i;
cp_class_binding *cb;
/* The IDENTIFIER_CLASS_VALUEs are no longer valid. */
for (t = previous_class_values; t; t = TREE_CHAIN (t))
IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (t)) = NULL_TREE;
for (i = 0;
(cb = VEC_iterate (cp_class_binding,
previous_class_level->class_shadowed, i));
++i)
IDENTIFIER_CLASS_VALUE (cb->identifier) = NULL_TREE;
previous_class_values = NULL_TREE;
previous_class_type = NULL_TREE;
previous_class_level = NULL;
}
/* Get out of the current class scope. If we were in a class scope
......
......@@ -640,8 +640,7 @@ struct saved_scope GTY(())
varray_type lang_base;
tree lang_name;
tree template_parms;
tree x_previous_class_type;
tree x_previous_class_values;
struct cp_binding_level *x_previous_class_level;
tree x_saved_tree;
HOST_WIDE_INT x_processing_template_decl;
......@@ -694,16 +693,10 @@ struct saved_scope GTY(())
#define processing_specialization scope_chain->x_processing_specialization
#define processing_explicit_instantiation scope_chain->x_processing_explicit_instantiation
/* _TYPE: the previous type that was a class */
/* The cached class binding level, from the most recently exited
class, or NULL if none. */
#define previous_class_type scope_chain->x_previous_class_type
/* This is a copy of the class_shadowed list of the previous class
binding contour when at global scope. It's used to reset
IDENTIFIER_CLASS_VALUEs when entering another class scope (i.e. a
cache miss). */
#define previous_class_values scope_chain->x_previous_class_values
#define previous_class_level scope_chain->x_previous_class_level
/* A list of private types mentioned, for deferred access checking. */
......
......@@ -443,7 +443,8 @@ poplevel (int keep, int reverse, int functionbody)
? ((functionbody = 0), tmp) : functionbody);
subblocks = functionbody >= 0 ? current_binding_level->blocks : 0;
my_friendly_assert (!current_binding_level->class_shadowed,
my_friendly_assert (VEC_length(cp_class_binding,
current_binding_level->class_shadowed) == 0,
19990414);
/* We used to use KEEP == 2 to indicate that the new block should go
......
......@@ -117,6 +117,15 @@ typedef enum scope_kind {
"template <>", this scope is always empty. */
} scope_kind;
typedef struct cp_class_binding GTY(())
{
cxx_binding base;
/* The bound name. */
tree identifier;
} cp_class_binding;
DEF_VEC_O(cp_class_binding);
/* For each binding contour we allocate a binding_level structure
which records the names defined in that contour.
Contours include:
......@@ -175,7 +184,7 @@ struct cp_binding_level GTY(())
class_shadowed is a TREE_LIST. The TREE_PURPOSE of each node
is the name of an entity bound in the class. The TREE_TYPE is
the DECL bound by this name in the class. */
tree class_shadowed;
VEC(cp_class_binding) *class_shadowed;
/* Similar to class_shadowed, but for IDENTIFIER_TYPE_VALUE, and
is used for all binding levels. In addition the TREE_VALUE is the
......@@ -273,6 +282,7 @@ extern void keep_next_level (bool);
extern bool is_ancestor (tree, tree);
extern bool push_scope (tree);
extern void pop_scope (tree);
extern void push_binding_level (struct cp_binding_level *);
extern void push_namespace (tree);
extern void pop_namespace (void);
......@@ -299,7 +309,6 @@ extern bool push_class_level_binding (tree, tree);
extern void storetags (tree);
extern tree getdecls (void);
extern tree cp_namespace_decls (tree);
extern void set_class_shadows (tree);
extern void set_decl_namespace (tree, tree, bool);
extern tree current_decl_namespace (void);
extern void push_decl_namespace (tree);
......
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