FreeBSD/contrib/gcc/cp/class.c
/* Returns the initializers for the vbase offset entries in the vtable
   for BINFO (which is part of the class hierarchy dominated by T), in
   reverse order.  VBASE_OFFSET_INDEX gives the vtable index
   where the next vbase offset will go.  */
Returns the initializers for the vbase offset entries in the vtable
for BINFO (which is part of the class hierarchy dominated by T), in
reverse order.  VBASE_OFFSET_INDEX gives the vtable index
where the next vbase offset will go.
Returns the initializers for the vbase offset entries in the vtable for BINFO ( which is part of the class hierarchy dominated by T ) in reverse order . VBASE_OFFSET_INDEX gives the vtable index where the next vbase offset will go .
static void
build_vbase_offset_vtbl_entries (tree binfo, vtbl_init_data* vid)
{
  tree vbase;
  tree t;
  tree non_primary_binfo;
  if (!CLASSTYPE_VBASECLASSES (BINFO_TYPE (binfo)))
    return;
  t = vid->derived;
  non_primary_binfo = binfo;
  while (BINFO_INHERITANCE_CHAIN (non_primary_binfo))
    {
      tree b;
      if (BINFO_VIRTUAL_P (non_primary_binfo))
	{
	  non_primary_binfo = vid->binfo;
	  break;
	}
      b = BINFO_INHERITANCE_CHAIN (non_primary_binfo);
      if (get_primary_binfo (b) != non_primary_binfo)
	break;
      non_primary_binfo = b;
    }
  for (vbase = TYPE_BINFO (BINFO_TYPE (binfo));
       vbase;
       vbase = TREE_CHAIN (vbase))
    {
      tree b;
      tree delta;
      if (!BINFO_VIRTUAL_P (vbase))
	continue;
      b = copied_binfo (vbase, binfo);
      if (BINFO_VTABLE_PATH_MARKED (b))
	continue;
      BINFO_VTABLE_PATH_MARKED (b) = 1;
      delta = size_binop (MULT_EXPR,
			  vid->index,
			  convert (ssizetype,
				   TYPE_SIZE_UNIT (vtable_entry_type)));
      if (vid->primary_vtbl_p)
	BINFO_VPTR_FIELD (b) = delta;
      if (binfo != TYPE_BINFO (t))
	gcc_assert (tree_int_cst_equal (delta, BINFO_VPTR_FIELD (vbase)));
      vid->index = size_binop (MINUS_EXPR, vid->index,
			       ssize_int (TARGET_VTABLE_DATA_ENTRY_DISTANCE));
      delta = size_diffop (BINFO_OFFSET (b), BINFO_OFFSET (non_primary_binfo));
      *vid->last_init
	= build_tree_list (NULL_TREE,
			   fold_build1 (NOP_EXPR,
					vtable_entry_type,
					delta));
      vid->last_init = &TREE_CHAIN (*vid->last_init);
    }
}
static void build_vbase_offset_vtbl_entries ( tree binfo , vtbl_init_data * vid ) { tree vbase ; tree t ; tree non_primary_binfo ; if ( ! CLASSTYPE_VBASECLASSES ( BINFO_TYPE ( binfo ) ) ) return ; t = vid -> derived ; non_primary_binfo = binfo ; while ( BINFO_INHERITANCE_CHAIN ( non_primary_binfo ) ) { tree b ; if ( BINFO_VIRTUAL_P ( non_primary_binfo ) ) { non_primary_binfo = vid -> binfo ; break ; } b = BINFO_INHERITANCE_CHAIN ( non_primary_binfo ) ; if ( get_primary_binfo ( b ) != non_primary_binfo ) break ; non_primary_binfo = b ; } for ( vbase = TYPE_BINFO ( BINFO_TYPE ( binfo ) ) ; vbase ; vbase = TREE_CHAIN ( vbase ) ) { tree b ; tree delta ; if ( ! BINFO_VIRTUAL_P ( vbase ) ) continue ; b = copied_binfo ( vbase , binfo ) ; if ( BINFO_VTABLE_PATH_MARKED ( b ) ) continue ; BINFO_VTABLE_PATH_MARKED ( b ) = 1 ; delta = size_binop ( MULT_EXPR , vid -> index , convert ( ssizetype , TYPE_SIZE_UNIT ( vtable_entry_type ) ) ) ; if ( vid -> primary_vtbl_p ) BINFO_VPTR_FIELD ( b ) = delta ; if ( binfo != TYPE_BINFO ( t ) ) gcc_assert ( tree_int_cst_equal ( delta , BINFO_VPTR_FIELD ( vbase ) ) ) ; vid -> index = size_binop ( MINUS_EXPR , vid -> index , ssize_int ( TARGET_VTABLE_DATA_ENTRY_DISTANCE ) ) ; delta = size_diffop ( BINFO_OFFSET ( b ) , BINFO_OFFSET ( non_primary_binfo ) ) ; * vid -> last_init = build_tree_list ( NULL_TREE , fold_build1 ( NOP_EXPR , vtable_entry_type , delta ) ) ; vid -> last_init = & TREE_CHAIN ( * vid -> last_init ) ; } }
Returns the initializers for the vbase offset entries in the vtable
for BINFO (which is part of the class hierarchy dominated by T), in
reverse order.
Returns the initializers for the vbase offset entries in the vtable for BINFO ( which is part of the class hierarchy dominated by T ) in reverse order .
/* If there are no virtual baseclasses, then there is nothing to
     do.  */ /* We might be a primary base class.  Go up the inheritance hierarchy
     until we find the most derived class of which we are a primary base:
     it is the offset of that which we need to use.  */ /* If we have reached a virtual base, then it must be a primary
	 base (possibly multi-level) of vid->binfo, or we wouldn't
	 have called build_vcall_and_vbase_vtbl_entries for it.  But it
	 might be a lost primary, so just skip down to vid->binfo.  */ /* Go through the virtual bases, adding the offsets.  */ /* Find the instance of this virtual base in the complete
	 object.  */ /* If we've already got an offset for this virtual base, we
	 don't need another one.  */ /* Figure out where we can find this vbase offset.  */ /* The vbase offset had better be the same.  */ /* The next vbase will come at a more negative offset.  */ /* The initializer is the delta from BINFO to this virtual base.
	 The vbase offsets go in reverse inheritance-graph order, and
	 we are walking in inheritance graph order so these end up in
	 the right order.  */