Commit 5b94d9dd by Nathan Sidwell Committed by Nathan Sidwell

class.c (dfs_modify_vtables): Simplify condition.

	* class.c (dfs_modify_vtables): Simplify condition. Return
	dfs_skip_bases as appropriate.
	(modify_all_vtables): Walk in pre-order.
	* search.c (dfs_walk_all, dfs_walk_once_r,
	dfs_walk_once_accessible_r): Assert post order function never
	returns dfs_skip_bases.

From-SVN: r88939
parent fa91adc6
2004-10-12 Nathan Sidwell <nathan@codesourcery.com> 2004-10-12 Nathan Sidwell <nathan@codesourcery.com>
* class.c (dfs_modify_vtables): Simplify condition. Return
dfs_skip_bases as appropriate.
(modify_all_vtables): Walk in pre-order.
* search.c (dfs_walk_all, dfs_walk_once_r,
dfs_walk_once_accessible_r): Assert post order function never
returns dfs_skip_bases.
* search.c (struct lookup_base_data_s): New. * search.c (struct lookup_base_data_s): New.
(lookup_base_r): Replace with ... (lookup_base_r): Replace with ...
(dfs_lookup_base): ... this. (dfs_lookup_base): ... this.
......
...@@ -2144,37 +2144,41 @@ static tree ...@@ -2144,37 +2144,41 @@ static tree
dfs_modify_vtables (tree binfo, void* data) dfs_modify_vtables (tree binfo, void* data)
{ {
tree t = (tree) data; tree t = (tree) data;
tree virtuals;
tree old_virtuals;
unsigned ix;
if (!TYPE_CONTAINS_VPTR_P (BINFO_TYPE (binfo)))
/* A base without a vtable needs no modification, and its bases
are uninteresting. */
return dfs_skip_bases;
if (/* There's no need to modify the vtable for a non-virtual if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), t)
primary base; we're not going to use that vtable anyhow. && !CLASSTYPE_HAS_PRIMARY_BASE_P (t))
We do still need to do this for virtual primary bases, as they /* Don't do the primary vtable, if it's new. */
could become non-primary in a construction vtable. */ return NULL_TREE;
(!BINFO_PRIMARY_P (binfo) || BINFO_VIRTUAL_P (binfo))
/* Similarly, a base without a vtable needs no modification. */ if (BINFO_PRIMARY_P (binfo) && !BINFO_VIRTUAL_P (binfo))
&& TYPE_CONTAINS_VPTR_P (BINFO_TYPE (binfo)) /* There's no need to modify the vtable for a non-virtual primary
/* Don't do the primary vtable, if it's new. */ base; we're not going to use that vtable anyhow. We do still
&& (!SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), t) need to do this for virtual primary bases, as they could become
|| CLASSTYPE_HAS_PRIMARY_BASE_P (t))) non-primary in a construction vtable. */
{ return NULL_TREE;
tree virtuals;
tree old_virtuals; make_new_vtable (t, binfo);
unsigned ix;
make_new_vtable (t, binfo);
/* Now, go through each of the virtual functions in the virtual /* Now, go through each of the virtual functions in the virtual
function table for BINFO. Find the final overrider, and function table for BINFO. Find the final overrider, and update
update the BINFO_VIRTUALS list appropriately. */ the BINFO_VIRTUALS list appropriately. */
for (ix = 0, virtuals = BINFO_VIRTUALS (binfo), for (ix = 0, virtuals = BINFO_VIRTUALS (binfo),
old_virtuals = BINFO_VIRTUALS (TYPE_BINFO (BINFO_TYPE (binfo))); old_virtuals = BINFO_VIRTUALS (TYPE_BINFO (BINFO_TYPE (binfo)));
virtuals; virtuals;
ix++, virtuals = TREE_CHAIN (virtuals), ix++, virtuals = TREE_CHAIN (virtuals),
old_virtuals = TREE_CHAIN (old_virtuals)) old_virtuals = TREE_CHAIN (old_virtuals))
update_vtable_entry_for_fn (t, update_vtable_entry_for_fn (t,
binfo, binfo,
BV_FN (old_virtuals), BV_FN (old_virtuals),
&virtuals, ix); &virtuals, ix);
}
return NULL_TREE; return NULL_TREE;
} }
...@@ -2195,7 +2199,7 @@ modify_all_vtables (tree t, tree virtuals) ...@@ -2195,7 +2199,7 @@ modify_all_vtables (tree t, tree virtuals)
tree *fnsp; tree *fnsp;
/* Update all of the vtables. */ /* Update all of the vtables. */
dfs_walk_once (binfo, NULL, dfs_modify_vtables, t); dfs_walk_once (binfo, dfs_modify_vtables, NULL, t);
/* Add virtual functions not already in our primary vtable. These /* Add virtual functions not already in our primary vtable. These
will be both those introduced by this class, and those overridden will be both those introduced by this class, and those overridden
......
...@@ -1542,7 +1542,12 @@ dfs_walk_all (tree binfo, tree (*pre_fn) (tree, void *), ...@@ -1542,7 +1542,12 @@ dfs_walk_all (tree binfo, tree (*pre_fn) (tree, void *),
skip_bases: skip_bases:
/* Call the post-order walking function. */ /* Call the post-order walking function. */
if (post_fn) if (post_fn)
return post_fn (binfo, data); {
rval = post_fn (binfo, data);
gcc_assert (rval != dfs_skip_bases);
return rval;
}
return NULL_TREE; return NULL_TREE;
} }
...@@ -1588,7 +1593,11 @@ dfs_walk_once_r (tree binfo, tree (*pre_fn) (tree, void *), ...@@ -1588,7 +1593,11 @@ dfs_walk_once_r (tree binfo, tree (*pre_fn) (tree, void *),
skip_bases: skip_bases:
/* Call the post-order walking function. */ /* Call the post-order walking function. */
if (post_fn) if (post_fn)
return post_fn (binfo, data); {
rval = post_fn (binfo, data);
gcc_assert (rval != dfs_skip_bases);
return rval;
}
return NULL_TREE; return NULL_TREE;
} }
...@@ -1710,7 +1719,11 @@ dfs_walk_once_accessible_r (tree binfo, bool friends_p, bool once, ...@@ -1710,7 +1719,11 @@ dfs_walk_once_accessible_r (tree binfo, bool friends_p, bool once,
skip_bases: skip_bases:
/* Call the post-order walking function. */ /* Call the post-order walking function. */
if (post_fn) if (post_fn)
return post_fn (binfo, data); {
rval = post_fn (binfo, data);
gcc_assert (rval != dfs_skip_bases);
return rval;
}
return NULL_TREE; return NULL_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