Commit 8026246f by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (CLASSTYPE_VFIELDS): Move definition.

2000-01-02  Mark Mitchell  <mark@codesourcery.com>

	* cp-tree.h (CLASSTYPE_VFIELDS): Move definition.
	(BINFO_PRIMARY_MARKED_P): Use flag 5.
	(SET_BINFO_PRIMARY_MARKED_P): Likewise.
	(CLEAR_BINFO_PRIMARY_MARKED_P): Likewise.
	(unmark_primary_bases): Remove declaration.
	(unmarkedp): Declare.
	(dfs_vbase_unmark): Likewise.
	* class.c (determine_primary_base): Return immediately if there
	are no base classes.  Call mark_primary_bases here.
	(modify_all_direct_vtables): Remove.
	(modify_all_indirect_vtables): Remove.
	(dfs_modify_vtables_queue_p): New function.
	(dfs_modify_vtables): New function.
	(modify_all_vtables): Use them.
	(build_base_fields): Build FIELD_DECLs for primary virtual base
	classes.
	(create_vtable_ptr): Don't call determine_primary_base here.
	(dfs_mark_primary_bases_and_set_vbase_offsets): Rename to ...
	(dfs_set_offset_for_vbases): ... this.
	(layout_virtual_bases): Use it.
	(layout_class_type): Call determine_primary_base here.
	* search.c (unmarkedp): Make it global.
	(shared_marked_p): Simplify.
	(shared_unmarked_p): Likewise.
	(dfs_primary_bases_queue_p): Remove.
	(dfs_unmark_primary_bases): Likewise.
	(unmark_primary_bases): Likewise.
	(mark_primary_bases): Simplify.
	(get_pure_virtuals): Don't call mark_primary_bases here.
	(dfs_vbase_unmark): New function.
	(get_vbase_types): Simplify.

From-SVN: r31175
parent d2c5305b
2000-01-02 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (CLASSTYPE_VFIELDS): Move definition.
(BINFO_PRIMARY_MARKED_P): Use flag 5.
(SET_BINFO_PRIMARY_MARKED_P): Likewise.
(CLEAR_BINFO_PRIMARY_MARKED_P): Likewise.
(unmark_primary_bases): Remove declaration.
(unmarkedp): Declare.
(dfs_vbase_unmark): Likewise.
* class.c (determine_primary_base): Return immediately if there
are no base classes. Call mark_primary_bases here.
(modify_all_direct_vtables): Remove.
(modify_all_indirect_vtables): Remove.
(dfs_modify_vtables_queue_p): New function.
(dfs_modify_vtables): New function.
(modify_all_vtables): Use them.
(build_base_fields): Build FIELD_DECLs for primary virtual base
classes.
(create_vtable_ptr): Don't call determine_primary_base here.
(dfs_mark_primary_bases_and_set_vbase_offsets): Rename to ...
(dfs_set_offset_for_vbases): ... this.
(layout_virtual_bases): Use it.
(layout_class_type): Call determine_primary_base here.
* search.c (unmarkedp): Make it global.
(shared_marked_p): Simplify.
(shared_unmarked_p): Likewise.
(dfs_primary_bases_queue_p): Remove.
(dfs_unmark_primary_bases): Likewise.
(unmark_primary_bases): Likewise.
(mark_primary_bases): Simplify.
(get_pure_virtuals): Don't call mark_primary_bases here.
(dfs_vbase_unmark): New function.
(get_vbase_types): Simplify.
* class.c (struct base_info): Remove.
(determine_primary_base): Take has_virtual_p rather than a
base_info as input. Don't calculate max_has_virtual.
......@@ -9,7 +41,7 @@
(layout_basetypes): Likewise.
(layout_class_type): Remove max_has_virtual_p argument.
(finish_struct_1): Remove max_has_virtual.
* cp-tree.h (dfs_mark_primary_bases_queue_p): New function.
(layout_basetypes): Remove.
* class.c (propagate_binfo_offsets): Moved here from tree.c.
......@@ -145,7 +177,6 @@
(build_vtbl_initializer): Likewise.
(override_one_vtable): Likewise.
(check_methods): Likewise.
* decl.c (duplicate_decls): Likewise.
(redeclaration_error_message): Likewise.
(lang_mark_tree): Likewise.
......
/* Definitions for C++ parsing and type checking.
Copyright (C) 1987, 92-97, 1998, 1999 Free Software Foundation, Inc.
Copyright (C) 1987, 92-97, 1998, 1999, 2000 Free Software Foundation, Inc.
Hacked by Michael Tiemann (tiemann@cygnus.com)
This file is part of GNU CC.
......@@ -1415,9 +1415,6 @@ struct lang_type
#define BINFO_FOR_VBASE(T, C) \
(binfo_member (T, CLASSTYPE_VBASECLASSES (C)))
/* The virtual function pointer fields that this type contains. */
#define CLASSTYPE_VFIELDS(NODE) (TYPE_LANG_SPECIFIC(NODE)->vfields)
/* Number of direct baseclasses of NODE. */
#define CLASSTYPE_N_BASECLASSES(NODE) \
(BINFO_N_BASETYPES (TYPE_BINFO (NODE)))
......@@ -1563,20 +1560,35 @@ struct lang_type
#define CLEAR_BINFO_PUSHDECLS_MARKED(NODE) CLEAR_BINFO_VTABLE_PATH_MARKED (NODE)
/* Nonzero if this BINFO has been marked as a primary base class. */
#define BINFO_PRIMARY_MARKED_P(NODE) BINFO_VTABLE_PATH_MARKED (NODE)
#define BINFO_PRIMARY_MARKED_P(NODE) \
(TREE_VIA_VIRTUAL (NODE) \
? CLASSTYPE_MARKED5 (BINFO_TYPE (NODE)) \
: TREE_LANG_FLAG_5 (NODE))
/* Mark NODE as a primary base class. */
#define SET_BINFO_PRIMARY_MARKED_P(NODE) SET_BINFO_VTABLE_PATH_MARKED (NODE)
#define SET_BINFO_PRIMARY_MARKED_P(NODE) \
(TREE_VIA_VIRTUAL (NODE) \
? SET_CLASSTYPE_MARKED5 (BINFO_TYPE (NODE)) \
: (TREE_LANG_FLAG_5 (NODE) = 1))
/* Clear the primary base class mark. */
#define CLEAR_BINFO_PRIMARY_MARKED_P(NODE) \
CLEAR_BINFO_VTABLE_PATH_MARKED (NODE)
#define CLEAR_BINFO_PRIMARY_MARKED_P(NODE) \
(TREE_VIA_VIRTUAL (NODE) \
? CLEAR_CLASSTYPE_MARKED5 (BINFO_TYPE (NODE)) \
: (TREE_LANG_FLAG_5 (NODE) = 0))
/* Used by various search routines. */
#define IDENTIFIER_MARKED(NODE) TREE_LANG_FLAG_0 (NODE)
/* Accessor macros for the vfield slots in structures. */
/* The virtual function pointer fields that this type contains. For a
vfield defined just for this class, or from a primary base, the
TREE_PURPOSE is NULL. Otherwise, the TREE_PURPOSE is the BINFO for
the class containing the vfield. The TREE_VALUE is the class where
the vfield was first defined. */
#define CLASSTYPE_VFIELDS(NODE) (TYPE_LANG_SPECIFIC(NODE)->vfields)
/* Get the assoc info that caused this vfield to exist. */
#define VF_BINFO_VALUE(NODE) TREE_PURPOSE (NODE)
......@@ -3908,10 +3920,11 @@ extern tree dfs_walk PROTO((tree,
tree (*) (tree, void *),
void *));
extern tree dfs_unmark PROTO((tree, void *));
extern tree dfs_vbase_unmark PROTO((tree, void *));
extern tree markedp PROTO((tree, void *));
extern tree unmarkedp PROTO((tree, void *));
extern tree dfs_mark_primary_bases_queue_p PROTO((tree, void *));
extern void mark_primary_bases PROTO((tree));
extern void unmark_primary_bases PROTO((tree));
/* in semantics.c */
extern void finish_expr_stmt PROTO((tree));
......
/* Breadth-first and depth-first routines for
searching multiple-inheritance lattice for GNU C++.
Copyright (C) 1987, 89, 92-97, 1998, 1999 Free Software Foundation, Inc.
Copyright (C) 1987, 89, 92-97, 1998, 1999, 2000 Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com)
This file is part of GNU CC.
......@@ -95,7 +95,6 @@ static void expand_upcast_fixups
static void fixup_virtual_upcast_offsets
PROTO((tree, tree, int, int, tree, tree, tree, tree,
tree *));
static tree unmarkedp PROTO((tree, void *));
static tree marked_vtable_pathp PROTO((tree, void *));
static tree unmarked_vtable_pathp PROTO((tree, void *));
static tree marked_new_vtablep PROTO((tree, void *));
......@@ -152,7 +151,6 @@ static void setup_class_bindings PROTO ((tree, int));
static int template_self_reference_p PROTO ((tree, tree));
static void fixup_all_virtual_upcast_offsets PROTO ((tree, tree));
static tree dfs_mark_primary_bases PROTO((tree, void *));
static tree dfs_unmark_primary_bases PROTO((tree, void *));
/* Allocate a level of searching. */
......@@ -777,7 +775,7 @@ shared_marked_p (binfo, data)
void *data;
{
binfo = canonical_binfo (binfo);
return markedp (binfo, data) ? binfo : NULL_TREE;
return markedp (binfo, data);
}
/* If BINFO is not marked, return a canonical version of BINFO.
......@@ -789,7 +787,7 @@ shared_unmarked_p (binfo, data)
void *data;
{
binfo = canonical_binfo (binfo);
return unmarkedp (binfo, data) ? binfo : NULL_TREE;
return unmarkedp (binfo, data);
}
/* Called from access_in_type via dfs_walk. Calculate the access to
......@@ -2124,65 +2122,15 @@ dfs_mark_primary_bases (binfo, data)
return NULL_TREE;
}
/* Called via dfs_walk from mark_primary_bases. */
tree
dfs_mark_primary_bases_queue_p (binfo, data)
tree binfo;
void *data ATTRIBUTE_UNUSED;
{
/* Don't walk into virtual baseclasses that are not primary
bases. */
if (TREE_VIA_VIRTUAL (binfo))
{
tree derived_class;
tree primary_base;
derived_class = BINFO_TYPE (BINFO_INHERITANCE_CHAIN (binfo));
primary_base = CLASSTYPE_PRIMARY_BINFO (derived_class);
if (!primary_base || !same_type_p (BINFO_TYPE (primary_base),
BINFO_TYPE (binfo)))
return NULL_TREE;
}
/* But do walk into everything else. */
return binfo;
}
/* Set BINFO_PRIMARY_MARKED_P for all binfos in the hierarchy
dominated by TYPE that are primary bases. (In addition,
BINFO_MARKED is set for all classes in the hierarchy; callers
should clear BINFO_MARKED.) */
dominated by BINFO that are primary bases. */
void
mark_primary_bases (type)
tree type;
{
dfs_walk (TYPE_BINFO (type),
dfs_mark_primary_bases,
dfs_mark_primary_bases_queue_p,
NULL);
}
/* Called from unmark_primary_bases via dfs_walk. */
static tree
dfs_unmark_primary_bases (binfo, data)
tree binfo;
void *data ATTRIBUTE_UNUSED;
{
CLEAR_BINFO_PRIMARY_MARKED_P (binfo);
return NULL_TREE;
}
/* Clear BINFO_PRIMARY_MARKED_P for all binfo in the hierarchy
dominated by TYPE. */
void
unmark_primary_bases (type)
tree type;
{
dfs_walk (TYPE_BINFO (type), dfs_unmark_primary_bases, NULL, NULL);
dfs_walk (TYPE_BINFO (type), dfs_mark_primary_bases, unmarkedp, NULL);
dfs_walk (TYPE_BINFO (type), dfs_unmark, markedp, NULL);
}
/* Called via dfs_walk from dfs_get_pure_virtuals. */
......@@ -2219,8 +2167,8 @@ dfs_get_pure_virtuals (binfo, data)
= tree_cons (NULL_TREE, TREE_VALUE (virtuals),
CLASSTYPE_PURE_VIRTUALS (type));
}
CLEAR_BINFO_MARKED (binfo);
SET_BINFO_MARKED (binfo);
return NULL_TREE;
}
......@@ -2236,17 +2184,15 @@ get_pure_virtuals (type)
/* Clear the CLASSTYPE_PURE_VIRTUALS list; whatever is already there
is going to be overridden. */
CLASSTYPE_PURE_VIRTUALS (type) = NULL_TREE;
/* Find all the primary bases. */
mark_primary_bases (type);
/* Now, run through all the bases which are not primary bases, and
collect the pure virtual functions. We look at the vtable in
each class to determine what pure virtual functions are present.
(A primary base is not interesting because the derived class of
which it is a primary base will contain vtable entries for the
pure virtuals in the base class. */
dfs_walk (TYPE_BINFO (type), dfs_get_pure_virtuals, markedp, type);
/* Now, clear the BINFO_PRIMARY_MARKED_P bit. */
unmark_primary_bases (type);
dfs_walk (TYPE_BINFO (type), dfs_get_pure_virtuals, unmarkedp, type);
dfs_walk (TYPE_BINFO (type), dfs_unmark, markedp, 0);
/* Put the pure virtuals in dfs order. */
CLASSTYPE_PURE_VIRTUALS (type) = nreverse (CLASSTYPE_PURE_VIRTUALS (type));
......@@ -2317,14 +2263,15 @@ convert_pointer_to_single_level (to_type, expr)
return NULL_TREE;
}
tree markedp (binfo, data)
tree
markedp (binfo, data)
tree binfo;
void *data ATTRIBUTE_UNUSED;
{
return BINFO_MARKED (binfo) ? binfo : NULL_TREE;
}
static tree
tree
unmarkedp (binfo, data)
tree binfo;
void *data ATTRIBUTE_UNUSED;
......@@ -2415,6 +2362,17 @@ dfs_unmark (binfo, data)
return NULL_TREE;
}
/* Clear both BINFO_MARKED and BINFO_VBASE_MARKED. */
tree
dfs_vbase_unmark (binfo, data)
tree binfo;
void *data ATTRIBUTE_UNUSED;
{
CLEAR_BINFO_VBASE_MARKED (binfo);
return dfs_unmark (binfo, data);
}
#if 0
static void
dfs_mark_vtable_path (binfo) tree binfo;
......@@ -2973,23 +2931,13 @@ void
get_vbase_types (type)
tree type;
{
tree vbase_types;
tree vbases;
tree binfo;
binfo = TYPE_BINFO (type);
vbase_types = NULL_TREE;
dfs_walk (binfo, dfs_get_vbase_types, unmarkedp, &vbase_types);
dfs_walk (binfo, dfs_unmark, markedp, 0);
CLASSTYPE_VBASECLASSES (type) = NULL_TREE;
dfs_walk (TYPE_BINFO (type), dfs_get_vbase_types, unmarkedp,
&CLASSTYPE_VBASECLASSES (type));
/* Rely upon the reverse dfs ordering from dfs_get_vbase_types, and now
reverse it so that we get normal dfs ordering. */
vbase_types = nreverse (vbase_types);
/* unmark marked vbases */
for (vbases = vbase_types; vbases; vbases = TREE_CHAIN (vbases))
CLEAR_BINFO_VBASE_MARKED (vbases);
CLASSTYPE_VBASECLASSES (type) = vbase_types;
CLASSTYPE_VBASECLASSES (type) = nreverse (CLASSTYPE_VBASECLASSES (type));
dfs_walk (TYPE_BINFO (type), dfs_vbase_unmark, markedp, 0);
}
/* Debug info for C++ classes can get very large; try to avoid
......
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