This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++] remove make_binfo


Hi,
this patch removes make_binfo. It had two uses
a) called from xref_basetypes, where it took a type
b) called from copy_base_binfos, where it took a binfo to shallow copy

and its internal logic was essentially of the form if (type) {...} else {...}.

built and tested on i686-pc-linux-gnu, installed as obvious.

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2004-07-12  Nathan Sidwell  <nathan@codesourcery.com>

	* cp-tree.h (make_binfo): Remove.
	* decl.c (xref_basetypes): Use make_tree_binfo directly.
	* tree.h (copy_base_binfos): Likewise.
	(make_binfo): Remove.

Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.1002
diff -c -3 -p -r1.1002 cp-tree.h
*** cp/cp-tree.h	12 Jul 2004 10:07:26 -0000	1.1002
--- cp/cp-tree.h	12 Jul 2004 16:17:44 -0000
*************** extern tree build_cplus_array_type		(tre
*** 4181,4187 ****
  extern tree hash_tree_cons			(tree, tree, tree);
  extern tree hash_tree_chain			(tree, tree);
  extern tree hash_chainon			(tree, tree);
- extern tree make_binfo				(tree, tree, tree, tree);
  extern int count_functions			(tree);
  extern int is_overloaded_fn			(tree);
  extern tree get_first_fn			(tree);
--- 4181,4186 ----
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1244
diff -c -3 -p -r1.1244 decl.c
*** cp/decl.c	12 Jul 2004 16:06:24 -0000	1.1244
--- cp/decl.c	12 Jul 2004 16:18:10 -0000
*************** xref_basetypes (tree ref, tree base_list
*** 9064,9070 ****
    /* The binfo slot should be empty, unless this is an (ill-formed)
       redefinition.  */
    my_friendly_assert (!TYPE_BINFO (ref) || TYPE_SIZE (ref), 20040706);
!   TYPE_BINFO (ref) = make_binfo (size_zero_node, ref, NULL_TREE, NULL_TREE);
    
    if (i)
      {
--- 9064,9073 ----
    /* The binfo slot should be empty, unless this is an (ill-formed)
       redefinition.  */
    my_friendly_assert (!TYPE_BINFO (ref) || TYPE_SIZE (ref), 20040706);
!   my_friendly_assert (TYPE_MAIN_VARIANT (ref) == ref, 20040712);
!   TYPE_BINFO (ref) = make_tree_binfo (BINFO_LANG_SLOTS);
!   BINFO_OFFSET (TYPE_BINFO (ref)) = size_zero_node;
!   BINFO_TYPE (TYPE_BINFO (ref)) = ref;
    
    if (i)
      {
*************** xref_basetypes (tree ref, tree base_list
*** 9115,9137 ****
  	      && (current_lang_depth () == 0))
  	    TYPE_FOR_JAVA (ref) = 1;
  	  
! 	  if (CLASS_TYPE_P (basetype))
  	    {
  	      base_binfo = TYPE_BINFO (basetype);
  
! 	      if (dependent_type_p (basetype))
! 		{
! 		  base_binfo = make_binfo (size_zero_node, basetype,
! 					   NULL_TREE, NULL_TREE);
! 		  BINFO_DEPENDENT_BASE_P (base_binfo) = 1;
! 		}
! 	      else
! 		my_friendly_assert (base_binfo, 20040706);
  	    }
  	  else
  	    {
! 	      base_binfo = make_binfo (size_zero_node, basetype,
! 				       NULL_TREE, NULL_TREE);
  	      BINFO_DEPENDENT_BASE_P (base_binfo) = 1;
  	    }
  	  
--- 9118,9134 ----
  	      && (current_lang_depth () == 0))
  	    TYPE_FOR_JAVA (ref) = 1;
  	  
! 	  if (CLASS_TYPE_P (basetype) && !dependent_type_p (basetype))
  	    {
  	      base_binfo = TYPE_BINFO (basetype);
  
! 	      my_friendly_assert (base_binfo, 20040706);
  	    }
  	  else
  	    {
! 	      base_binfo = make_tree_binfo (BINFO_LANG_SLOTS);
! 	      
! 	      BINFO_TYPE (base_binfo) = basetype;
  	      BINFO_DEPENDENT_BASE_P (base_binfo) = 1;
  	    }
  	  
Index: cp/tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/tree.c,v
retrieving revision 1.390
diff -c -3 -p -r1.390 tree.c
*** cp/tree.c	12 Jul 2004 16:06:38 -0000	1.390
--- cp/tree.c	12 Jul 2004 16:19:35 -0000
*************** copy_base_binfos (tree binfo, tree t, tr
*** 617,625 ****
        
        if (!new_binfo)
  	{
! 	  new_binfo = make_binfo (BINFO_OFFSET (base_binfo),
! 				  base_binfo, NULL_TREE,
! 				  BINFO_VIRTUALS (base_binfo));
  	  prev = copy_base_binfos (new_binfo, t, prev);
  	  if (BINFO_VIRTUAL_P (base_binfo))
  	    {
--- 617,635 ----
        
        if (!new_binfo)
  	{
! 	  new_binfo = make_tree_binfo (BINFO_LANG_SLOTS);
! 
! 	  BINFO_TYPE (new_binfo) = BINFO_TYPE (base_binfo);
! 	  BINFO_OFFSET (new_binfo) = BINFO_OFFSET (base_binfo);
! 	  BINFO_VIRTUALS (new_binfo) = BINFO_VIRTUALS (base_binfo);
! 
! 	  if (BINFO_BASE_BINFOS (base_binfo))
! 	    /* Duplicate the binfo's base vector, so we can recurse.  */
! 	    BINFO_BASE_BINFOS (new_binfo)
! 	      = copy_node (BINFO_BASE_BINFOS (base_binfo));
! 	  /* We do not need to copy the accesses, as they are read only.  */
! 	  BINFO_BASE_ACCESSES (new_binfo) = BINFO_BASE_ACCESSES (base_binfo);
! 	  
  	  prev = copy_base_binfos (new_binfo, t, prev);
  	  if (BINFO_VIRTUAL_P (base_binfo))
  	    {
*************** hash_chainon (tree list1, tree list2)
*** 753,804 ****
  			  hash_chainon (TREE_CHAIN (list1), list2));
  }
  
- /* Build an association between TYPE and some parameters:
- 
-    OFFSET is the offset added to `this' to convert it to a pointer
-    of type `TYPE *'
- 
-    BINFO is the base binfo to use, if we are deriving from one.  This
-    is necessary, as we want specialized parent binfos from base
-    classes, so that the VTABLE_NAMEs of bases are for the most derived
-    type, instead of the simple type.
- 
-    VTABLE is the virtual function table with which to initialize
-    sub-objects of type TYPE.
- 
-    VIRTUALS are the virtual functions sitting in VTABLE.  */
- 
- tree
- make_binfo (tree offset, tree binfo, tree vtable, tree virtuals)
- {
-   tree new_binfo = make_tree_binfo (BINFO_LANG_SLOTS);
-   tree type;
- 
-   if (TREE_CODE (binfo) == TREE_BINFO)
-     {
-       type = BINFO_TYPE (binfo);
-       my_friendly_assert (!BINFO_DEPENDENT_BASE_P (binfo), 20040706);
-     }
-   else
-     {
-       type = binfo;
-       binfo = NULL_TREE;
-     }
- 
-   TREE_TYPE (new_binfo) = TYPE_MAIN_VARIANT (type);
-   BINFO_OFFSET (new_binfo) = offset;
-   BINFO_VTABLE (new_binfo) = vtable;
-   BINFO_VIRTUALS (new_binfo) = virtuals;
- 
-   if (binfo && BINFO_BASE_BINFOS (binfo))
-     {
-       BINFO_BASE_BINFOS (new_binfo) = copy_node (BINFO_BASE_BINFOS (binfo));
-       /* We do not need to copy the accesses, as they are read only.  */
-       BINFO_BASE_ACCESSES (new_binfo) = BINFO_BASE_ACCESSES (binfo);
-     }
-   return new_binfo;
- }
- 
  void
  debug_binfo (tree elem)
  {
--- 763,768 ----

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]