Eliminate 'is_ancestor' redundant code.
2010-10-12 Sami Wagiaalla <swagiaal@redhat.com> * gdbtypes.c (do_is_ancestor): New function. (is_ancestor): Use do_is_ancestor. (is_public_ancestor): Use do_is_ancestor.
This commit is contained in:
parent
bb32aa18f6
commit
0526b37ab5
2 changed files with 29 additions and 25 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2010-10-12 Sami Wagiaalla <swagiaal@redhat.com>
|
||||||
|
|
||||||
|
* gdbtypes.c (do_is_ancestor): New function.
|
||||||
|
(is_ancestor): Use do_is_ancestor.
|
||||||
|
(is_public_ancestor): Use do_is_ancestor.
|
||||||
|
|
||||||
2010-10-12 Pierre Muller <muller@ics.u-strasbg.fr>
|
2010-10-12 Pierre Muller <muller@ics.u-strasbg.fr>
|
||||||
|
|
||||||
* ser-go32.c (struct dos_ops): Add missing fdopen field.
|
* ser-go32.c (struct dos_ops): Add missing fdopen field.
|
||||||
|
|
|
@ -1868,14 +1868,13 @@ class_types_same_p (const struct type *a, const struct type *b)
|
||||||
&& !strcmp (TYPE_NAME (a), TYPE_NAME (b))));
|
&& !strcmp (TYPE_NAME (a), TYPE_NAME (b))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check whether BASE is an ancestor or base class or DCLASS
|
/* Check whether BASE is an ancestor or base class of DCLASS
|
||||||
Return 1 if so, and 0 if not.
|
Return 1 if so, and 0 if not. If PUBLIC is 1 then only public
|
||||||
Note: callers may want to check for identity of the types before
|
ancestors are considered, and the function returns 1 only if
|
||||||
calling this function -- identical types are considered to satisfy
|
BASE is a public ancestor of DCLASS. */
|
||||||
the ancestor relationship even if they're identical. */
|
|
||||||
|
|
||||||
int
|
static int
|
||||||
is_ancestor (struct type *base, struct type *dclass)
|
do_is_ancestor (struct type *base, struct type *dclass, int public)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -1887,36 +1886,35 @@ is_ancestor (struct type *base, struct type *dclass)
|
||||||
|
|
||||||
for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++)
|
for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++)
|
||||||
{
|
{
|
||||||
if (is_ancestor (base, TYPE_BASECLASS (dclass, i)))
|
if (public && ! BASETYPE_VIA_PUBLIC (dclass, i))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (do_is_ancestor (base, TYPE_BASECLASS (dclass, i), public))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check whether BASE is an ancestor or base class or DCLASS
|
||||||
|
Return 1 if so, and 0 if not.
|
||||||
|
Note: If BASE and DCLASS are of the same type, this function
|
||||||
|
will return 1. So for some class A, is_ancestor (A, A) will
|
||||||
|
return 1. */
|
||||||
|
|
||||||
|
int
|
||||||
|
is_ancestor (struct type *base, struct type *dclass)
|
||||||
|
{
|
||||||
|
return do_is_ancestor (base, dclass, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Like is_ancestor, but only returns true when BASE is a public
|
/* Like is_ancestor, but only returns true when BASE is a public
|
||||||
ancestor of DCLASS. */
|
ancestor of DCLASS. */
|
||||||
|
|
||||||
int
|
int
|
||||||
is_public_ancestor (struct type *base, struct type *dclass)
|
is_public_ancestor (struct type *base, struct type *dclass)
|
||||||
{
|
{
|
||||||
int i;
|
return do_is_ancestor (base, dclass, 1);
|
||||||
|
|
||||||
CHECK_TYPEDEF (base);
|
|
||||||
CHECK_TYPEDEF (dclass);
|
|
||||||
|
|
||||||
if (class_types_same_p (base, dclass))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
for (i = 0; i < TYPE_N_BASECLASSES (dclass); ++i)
|
|
||||||
{
|
|
||||||
if (! BASETYPE_VIA_PUBLIC (dclass, i))
|
|
||||||
continue;
|
|
||||||
if (is_public_ancestor (base, TYPE_BASECLASS (dclass, i)))
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A helper function for is_unique_ancestor. */
|
/* A helper function for is_unique_ancestor. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue