FreeBSD/contrib/gcc/cp/class.c
/* Determine all the primary bases within T.  Sets BINFO_PRIMARY_BASE_P for
   those that are primaries.  Sets BINFO_LOST_PRIMARY_P for those
   that have had a nearly-empty virtual primary base stolen by some
   other base in the hierarchy.  Determines CLASSTYPE_PRIMARY_BASE for
   T.  */
Determine all the primary bases within T.  Sets BINFO_PRIMARY_BASE_P for
those that are primaries.  Sets BINFO_LOST_PRIMARY_P for those
that have had a nearly-empty virtual primary base stolen by some
other base in the hierarchy.  Determines CLASSTYPE_PRIMARY_BASE for
T.
Determine all the primary bases within T . Sets BINFO_PRIMARY_BASE_P for those that are primaries . Sets BINFO_LOST_PRIMARY_P for those that have had a nearly - empty virtual primary base stolen by some other base in the hierarchy . Determines CLASSTYPE_PRIMARY_BASE for T .
static void
determine_primary_bases (tree t)
{
  unsigned i;
  tree primary = NULL_TREE;
  tree type_binfo = TYPE_BINFO (t);
  tree base_binfo;
  for (base_binfo = TREE_CHAIN (type_binfo); base_binfo;
       base_binfo = TREE_CHAIN (base_binfo))
    {
      tree primary = CLASSTYPE_PRIMARY_BINFO (BINFO_TYPE (base_binfo));
      if (!BINFO_VIRTUAL_P (base_binfo))
	{
	  tree parent = BINFO_INHERITANCE_CHAIN (base_binfo);
	  tree parent_primary = CLASSTYPE_PRIMARY_BINFO (BINFO_TYPE (parent));
	  if (parent_primary
	      && SAME_BINFO_TYPE_P (BINFO_TYPE (base_binfo),
				    BINFO_TYPE (parent_primary)))
	    BINFO_PRIMARY_P (base_binfo) = 1;
	}
      if (primary && BINFO_VIRTUAL_P (primary))
	{
	  tree this_primary = copied_binfo (primary, base_binfo);
	  if (BINFO_PRIMARY_P (this_primary))
	    BINFO_LOST_PRIMARY_P (base_binfo) = 1;
	  else
	    {
	      tree delta;
	      BINFO_PRIMARY_P (this_primary) = 1;
	      BINFO_INHERITANCE_CHAIN (this_primary) = base_binfo;
	      delta = size_diffop (convert (ssizetype,
					    BINFO_OFFSET (base_binfo)),
				   convert (ssizetype,
					    BINFO_OFFSET (this_primary)));
	      propagate_binfo_offsets (this_primary, delta);
	    }
	}
    }
  for (i = 0; BINFO_BASE_ITERATE (type_binfo, i, base_binfo); i++)
    {
      tree basetype = BINFO_TYPE (base_binfo);
      if (TYPE_CONTAINS_VPTR_P (basetype) && !BINFO_VIRTUAL_P (base_binfo))
	{
	  primary = base_binfo;
	  goto found;
	}
    }
  for (base_binfo = TREE_CHAIN (type_binfo); base_binfo;
       base_binfo = TREE_CHAIN (base_binfo))
    if (BINFO_VIRTUAL_P (base_binfo)
	&& CLASSTYPE_NEARLY_EMPTY_P (BINFO_TYPE (base_binfo)))
      {
	if (!BINFO_PRIMARY_P (base_binfo))
	  {
	    primary = base_binfo;
	    goto found;
	  }
	else if (!primary)
	  primary = base_binfo;
      }
 found:
  if (primary)
    {
      tree basetype = BINFO_TYPE (primary);
      CLASSTYPE_PRIMARY_BINFO (t) = primary;
      if (BINFO_PRIMARY_P (primary))
	BINFO_LOST_PRIMARY_P (BINFO_INHERITANCE_CHAIN (primary)) = 1;
      BINFO_PRIMARY_P (primary) = 1;
      if (BINFO_VIRTUAL_P (primary))
	{
	  tree delta;
	  BINFO_INHERITANCE_CHAIN (primary) = type_binfo;
	  delta = size_diffop (ssize_int (0),
			       convert (ssizetype, BINFO_OFFSET (primary)));
	  propagate_binfo_offsets (primary, delta);
	}
      primary = TYPE_BINFO (basetype);
      TYPE_VFIELD (t) = TYPE_VFIELD (basetype);
      BINFO_VTABLE (type_binfo) = BINFO_VTABLE (primary);
      BINFO_VIRTUALS (type_binfo) = BINFO_VIRTUALS (primary);
    }
}
static void determine_primary_bases ( tree t ) { unsigned i ; tree primary = NULL_TREE ; tree type_binfo = TYPE_BINFO ( t ) ; tree base_binfo ; for ( base_binfo = TREE_CHAIN ( type_binfo ) ; base_binfo ; base_binfo = TREE_CHAIN ( base_binfo ) ) { tree primary = CLASSTYPE_PRIMARY_BINFO ( BINFO_TYPE ( base_binfo ) ) ; if ( ! BINFO_VIRTUAL_P ( base_binfo ) ) { tree parent = BINFO_INHERITANCE_CHAIN ( base_binfo ) ; tree parent_primary = CLASSTYPE_PRIMARY_BINFO ( BINFO_TYPE ( parent ) ) ; if ( parent_primary && SAME_BINFO_TYPE_P ( BINFO_TYPE ( base_binfo ) , BINFO_TYPE ( parent_primary ) ) ) BINFO_PRIMARY_P ( base_binfo ) = 1 ; } if ( primary && BINFO_VIRTUAL_P ( primary ) ) { tree this_primary = copied_binfo ( primary , base_binfo ) ; if ( BINFO_PRIMARY_P ( this_primary ) ) BINFO_LOST_PRIMARY_P ( base_binfo ) = 1 ; else { tree delta ; BINFO_PRIMARY_P ( this_primary ) = 1 ; BINFO_INHERITANCE_CHAIN ( this_primary ) = base_binfo ; delta = size_diffop ( convert ( ssizetype , BINFO_OFFSET ( base_binfo ) ) , convert ( ssizetype , BINFO_OFFSET ( this_primary ) ) ) ; propagate_binfo_offsets ( this_primary , delta ) ; } } } for ( i = 0 ; BINFO_BASE_ITERATE ( type_binfo , i , base_binfo ) ; i ++ ) { tree basetype = BINFO_TYPE ( base_binfo ) ; if ( TYPE_CONTAINS_VPTR_P ( basetype ) && ! BINFO_VIRTUAL_P ( base_binfo ) ) { primary = base_binfo ; goto found ; } } for ( base_binfo = TREE_CHAIN ( type_binfo ) ; base_binfo ; base_binfo = TREE_CHAIN ( base_binfo ) ) if ( BINFO_VIRTUAL_P ( base_binfo ) && CLASSTYPE_NEARLY_EMPTY_P ( BINFO_TYPE ( base_binfo ) ) ) { if ( ! BINFO_PRIMARY_P ( base_binfo ) ) { primary = base_binfo ; goto found ; } else if ( ! primary ) primary = base_binfo ; } found : if ( primary ) { tree basetype = BINFO_TYPE ( primary ) ; CLASSTYPE_PRIMARY_BINFO ( t ) = primary ; if ( BINFO_PRIMARY_P ( primary ) ) BINFO_LOST_PRIMARY_P ( BINFO_INHERITANCE_CHAIN ( primary ) ) = 1 ; BINFO_PRIMARY_P ( primary ) = 1 ; if ( BINFO_VIRTUAL_P ( primary ) ) { tree delta ; BINFO_INHERITANCE_CHAIN ( primary ) = type_binfo ; delta = size_diffop ( ssize_int ( 0 ) , convert ( ssizetype , BINFO_OFFSET ( primary ) ) ) ; propagate_binfo_offsets ( primary , delta ) ; } primary = TYPE_BINFO ( basetype ) ; TYPE_VFIELD ( t ) = TYPE_VFIELD ( basetype ) ; BINFO_VTABLE ( type_binfo ) = BINFO_VTABLE ( primary ) ; BINFO_VIRTUALS ( type_binfo ) = BINFO_VIRTUALS ( primary ) ; } }
Determine all the primary bases within T.  Sets BINFO_PRIMARY_BASE_P for
those that are primaries.
Determine all the primary bases within T . Sets BINFO_PRIMARY_BASE_P for those that are primaries .
/* Determine the primary bases of our bases.  */ /* See if we're the non-virtual primary of our inheritance
	 chain.  */ /* We are the primary binfo.  */ /* Determine if we have a virtual primary base, and mark it so.
       */ /* Someone already claimed this base.  */ /* A virtual binfo might have been copied from within
		 another hierarchy. As we're about to use it as a
		 primary base, make sure the offsets match.  */ /* First look for a dynamic direct non-virtual base.  */ /* A "nearly-empty" virtual base class can be the primary base
     class, if no non-virtual polymorphic base can be found.  Look for
     a nearly-empty virtual dynamic base that is not already a primary
     base of something in the hierarchy.  If there is no such base,
     just pick the first nearly-empty virtual base.  */ /* Found one that is not primary.  */ /* Remember the first candidate.  */ /* If we've got a primary base, use it.  */ /* We are stealing a primary base.  */ /* A virtual binfo might have been copied from within
	     another hierarchy. As we're about to use it as a primary
	     base, make sure the offsets match.  */