[C++] Convert to fold_buildN

Steven Bosscher stevenb@suse.de
Wed Mar 23 11:59:00 GMT 2005


Hi,

Boostrapped and tested on {ppc,x86_64}-suse-linux-gnu, OK?

Gr.
Steven


2005-03-23  Steven Bosscher  <stevenb@suse.de>

	* class.c (build_base_path):
	(build_vbase_offset_vtbl_entries):
	(add_vcall_offset): Replace fold (buildN (...)) with fold_buildN.
	* error.c (dump_expr): Likewise.
	* init.c (build_zero_init, expand_cleanup_for_base,
	build_vec_delete_1): Likewise.
	* mangle.c (write_integer_cst): Likewise.
	* method.c (thunk_adjust): Likewise.
	* pt.c (convert_nontype_argument, tsubst, unify): Likewise.
	* tree.c (cxx_print_statistics, array_type_nelts_total): Likewise.
	* typeck.c (build_ptrmemfunc_access_expr,
	(get_member_function_from_ptrfunc): Likewise.

Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.709
diff -u -3 -p -r1.709 class.c
--- class.c	7 Mar 2005 23:08:57 -0000	1.709
+++ class.c	23 Mar 2005 11:18:43 -0000
@@ -296,8 +296,8 @@ build_base_path (enum tree_code code,
   if (null_test)
     {
       tree zero = cp_convert (TREE_TYPE (expr), integer_zero_node);
-      null_test = fold (build2 (NE_EXPR, boolean_type_node,
-				expr, zero));
+      null_test = fold_build2 (NE_EXPR, boolean_type_node,
+			       expr, zero);
     }
 
   /* If this is a simple base reference, express it as a COMPONENT_REF.  */
@@ -388,9 +388,9 @@ build_base_path (enum tree_code code,
 
  out:
   if (null_test)
-    expr = fold (build3 (COND_EXPR, target_type, null_test, expr,
-			 fold (build1 (NOP_EXPR, target_type,
-				       integer_zero_node))));
+    expr = fold_build3 (COND_EXPR, target_type, null_test, expr,
+			fold_build1 (NOP_EXPR, target_type,
+				     integer_zero_node));
 
   return expr;
 }
@@ -7406,9 +7406,9 @@ build_vbase_offset_vtbl_entries (tree bi
       
       *vid->last_init 
 	= build_tree_list (NULL_TREE,
-			   fold (build1 (NOP_EXPR, 
-					 vtable_entry_type,
-					 delta)));
+			   fold_build1 (NOP_EXPR, 
+					vtable_entry_type,
+					delta));
       vid->last_init = &TREE_CHAIN (*vid->last_init);
     }
 }
@@ -7633,8 +7633,8 @@ add_vcall_offset (tree orig_fn, tree bin
 	     BINFO_OFFSET from vid->binfo.  */
 	  vcall_offset = size_diffop (BINFO_OFFSET (base),
 				      BINFO_OFFSET (vid->binfo));
-	  vcall_offset = fold (build1 (NOP_EXPR, vtable_entry_type,
-				       vcall_offset));
+	  vcall_offset = fold_build1 (NOP_EXPR, vtable_entry_type,
+				      vcall_offset);
 	}
       /* Add the initializer to the vtable.  */
       *vid->last_init = build_tree_list (NULL_TREE, vcall_offset);
Index: error.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/error.c,v
retrieving revision 1.279
diff -u -3 -p -r1.279 error.c
--- error.c	24 Feb 2005 21:55:15 -0000	1.279
+++ error.c	23 Mar 2005 11:18:44 -0000
@@ -1413,9 +1413,9 @@ dump_expr (tree t, int flags)
 	if (TREE_CODE (type) == ARRAY_REF)
 	  type = build_cplus_array_type
 	    (TREE_OPERAND (type, 0),
-	     build_index_type (fold (build2 (MINUS_EXPR, integer_type_node,
-					     TREE_OPERAND (type, 1),
-					     integer_one_node))));
+	     build_index_type (fold_build2 (MINUS_EXPR, integer_type_node,
+					    TREE_OPERAND (type, 1),
+					    integer_one_node)));
 	dump_type (type, flags);
 	if (init)
 	  {
Index: init.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/init.c,v
retrieving revision 1.415
diff -u -3 -p -r1.415 init.c
--- init.c	21 Mar 2005 11:49:30 -0000	1.415
+++ init.c	23 Mar 2005 11:18:45 -0000
@@ -222,8 +222,8 @@ build_zero_init (tree type, tree nelts, 
       /* Iterate over the array elements, building initializations.  */
       inits = NULL_TREE;
       if (nelts)
-	max_index = fold (build2 (MINUS_EXPR, TREE_TYPE (nelts),
-				  nelts, integer_one_node));
+	max_index = fold_build2 (MINUS_EXPR, TREE_TYPE (nelts),
+				 nelts, integer_one_node);
       else
 	max_index = array_type_nelts (type);
       gcc_assert (TREE_CODE (max_index) == INTEGER_CST);
@@ -826,9 +826,9 @@ expand_cleanup_for_base (tree binfo, tre
 				    binfo,
 				    LOOKUP_NORMAL | LOOKUP_NONVIRTUAL);
   if (flag)
-    expr = fold (build3 (COND_EXPR, void_type_node,
-			 c_common_truthvalue_conversion (flag),
-			 expr, integer_zero_node));
+    expr = fold_build3 (COND_EXPR, void_type_node,
+			c_common_truthvalue_conversion (flag),
+			expr, integer_zero_node);
 
   finish_eh_cleanup (expr);
 }
@@ -2241,9 +2241,9 @@ build_vec_delete_1 (tree base, tree maxi
 
   tbase = create_temporary_var (ptype);
   tbase_init = build_modify_expr (tbase, NOP_EXPR,
-				  fold (build2 (PLUS_EXPR, ptype,
-						base,
-						virtual_size)));
+				  fold_build2 (PLUS_EXPR, ptype,
+					       base,
+					       virtual_size));
   DECL_REGISTER (tbase) = 1;
   controller = build3 (BIND_EXPR, void_type_node, tbase,
 		       NULL_TREE, NULL_TREE);
@@ -2308,11 +2308,11 @@ build_vec_delete_1 (tree base, tree maxi
     body = integer_zero_node;
   
   /* Outermost wrapper: If pointer is null, punt.  */
-  body = fold (build3 (COND_EXPR, void_type_node,
-		       fold (build2 (NE_EXPR, boolean_type_node, base,
-				     convert (TREE_TYPE (base),
-					      integer_zero_node))),
-		       body, integer_zero_node));
+  body = fold_build3 (COND_EXPR, void_type_node,
+		      fold_build2 (NE_EXPR, boolean_type_node, base,
+				   convert (TREE_TYPE (base),
+					    integer_zero_node)),
+		      body, integer_zero_node);
   body = build1 (NOP_EXPR, void_type_node, body);
 
   if (controller)
Index: mangle.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/mangle.c,v
retrieving revision 1.116
diff -u -3 -p -r1.116 mangle.c
--- mangle.c	24 Feb 2005 21:55:15 -0000	1.116
+++ mangle.c	23 Mar 2005 11:18:46 -0000
@@ -1249,16 +1249,16 @@ write_integer_cst (const tree cst)
       if (sign < 0)
 	{
 	  write_char ('n');
-	  n = fold (build1 (NEGATE_EXPR, type, n));
+	  n = fold_build1 (NEGATE_EXPR, type, n);
 	}
       do
 	{
-	  tree d = fold (build2 (FLOOR_DIV_EXPR, type, n, base));
-	  tree tmp = fold (build2 (MULT_EXPR, type, d, base));
+	  tree d = fold_build2 (FLOOR_DIV_EXPR, type, n, base);
+	  tree tmp = fold_build2 (MULT_EXPR, type, d, base);
 	  unsigned c;
 
 	  done = integer_zerop (d);
-	  tmp = fold (build2 (MINUS_EXPR, type, n, tmp));
+	  tmp = fold_build2 (MINUS_EXPR, type, n, tmp);
 	  c = hwint_to_ascii (TREE_INT_CST_LOW (tmp), 10, ptr,
 			      done ? 1 : chunk_digits);
 	  ptr -= c;
Index: method.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/method.c,v
retrieving revision 1.323
diff -u -3 -p -r1.323 method.c
--- method.c	1 Mar 2005 09:57:39 -0000	1.323
+++ method.c	23 Mar 2005 11:18:46 -0000
@@ -220,8 +220,8 @@ thunk_adjust (tree ptr, bool this_adjust
 {
   if (this_adjusting)
     /* Adjust the pointer by the constant.  */
-    ptr = fold (build2 (PLUS_EXPR, TREE_TYPE (ptr), ptr,
-			ssize_int (fixed_offset)));
+    ptr = fold_build2 (PLUS_EXPR, TREE_TYPE (ptr), ptr,
+		       ssize_int (fixed_offset));
 
   /* If there's a virtual offset, look up that value in the vtable and
      adjust the pointer again.  */
@@ -242,13 +242,13 @@ thunk_adjust (tree ptr, bool this_adjust
       /* Get the offset itself.  */
       vtable = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (vtable)), vtable);
       /* Adjust the `this' pointer.  */
-      ptr = fold (build2 (PLUS_EXPR, TREE_TYPE (ptr), ptr, vtable));
+      ptr = fold_build2 (PLUS_EXPR, TREE_TYPE (ptr), ptr, vtable);
     }
   
   if (!this_adjusting)
     /* Adjust the pointer by the constant.  */
-    ptr = fold (build2 (PLUS_EXPR, TREE_TYPE (ptr), ptr,
-			ssize_int (fixed_offset)));
+    ptr = fold_build2 (PLUS_EXPR, TREE_TYPE (ptr), ptr,
+		       ssize_int (fixed_offset));
 
   return ptr;
 }
Index: pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.985
diff -u -3 -p -r1.985 pt.c
--- pt.c	17 Mar 2005 13:26:39 -0000	1.985
+++ pt.c	23 Mar 2005 11:18:50 -0000
@@ -3612,7 +3612,7 @@ convert_nontype_argument (tree type, tre
       if (!expr || expr == error_mark_node)
 	return expr;
 
-      expr = build_nop(type, build_address (expr));
+      expr = build_nop (type, build_address (expr));
     }
   /* [temp.arg.nontype]/5, bullet 6
 
@@ -7342,7 +7342,7 @@ tsubst (tree t, tree args, tsubst_flags_
 	if (e1 == error_mark_node || e2 == error_mark_node)
 	  return error_mark_node;
 
-	return fold (build2 (TREE_CODE (t), TREE_TYPE (t), e1, e2));
+	return fold_build2 (TREE_CODE (t), TREE_TYPE (t), e1, e2);
       }
 
     case NEGATE_EXPR:
@@ -7352,7 +7352,7 @@ tsubst (tree t, tree args, tsubst_flags_
 	if (e == error_mark_node)
 	  return error_mark_node;
 
-	return fold (build1 (TREE_CODE (t), TREE_TYPE (t), e));
+	return fold_build1 (TREE_CODE (t), TREE_TYPE (t), e);
       }
 
     case TYPENAME_TYPE:
@@ -10158,10 +10158,10 @@ unify (tree tparms, tree targs, tree par
 	     not an integer constant.  */
 	  if (TREE_CODE (parm_max) == MINUS_EXPR)
 	    {
-	      arg_max = fold (build2 (PLUS_EXPR, 
-				      integer_type_node,
-				      arg_max,
-				      TREE_OPERAND (parm_max, 1)));
+	      arg_max = fold_build2 (PLUS_EXPR, 
+				     integer_type_node,
+				     arg_max,
+				     TREE_OPERAND (parm_max, 1));
 	      parm_max = TREE_OPERAND (parm_max, 0);
 	    }
 
Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/tree.c,v
retrieving revision 1.427
diff -u -3 -p -r1.427 tree.c
--- tree.c	21 Feb 2005 23:12:27 -0000	1.427
+++ tree.c	23 Mar 2005 11:18:51 -0000
@@ -1112,9 +1112,9 @@ cxx_print_statistics (void)
 tree
 array_type_nelts_top (tree type)
 {
-  return fold (build2 (PLUS_EXPR, sizetype,
-		       array_type_nelts (type),
-		       integer_one_node));
+  return fold_build2 (PLUS_EXPR, sizetype,
+		      array_type_nelts (type),
+		      integer_one_node);
 }
 
 /* Return, as an INTEGER_CST node, the number of elements for TYPE
@@ -1129,7 +1129,7 @@ array_type_nelts_total (tree type)
   while (TREE_CODE (type) == ARRAY_TYPE)
     {
       tree n = array_type_nelts_top (type);
-      sz = fold (build2 (MULT_EXPR, sizetype, sz, n));
+      sz = fold_build2 (MULT_EXPR, sizetype, sz, n);
       type = TREE_TYPE (type);
     }
   return sz;
Index: typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.620
diff -u -3 -p -r1.620 typeck.c
--- typeck.c	22 Mar 2005 09:30:06 -0000	1.620
+++ typeck.c	23 Mar 2005 11:18:53 -0000
@@ -1995,8 +1995,8 @@ build_ptrmemfunc_access_expr (tree ptrme
 			  /*want_type=*/false);
   member_type = cp_build_qualified_type (TREE_TYPE (member),
 					 cp_type_quals (ptrmem_type));
-  return fold (build3 (COMPONENT_REF, member_type,
-		       ptrmem, member, NULL_TREE));
+  return fold_build3 (COMPONENT_REF, member_type,
+		      ptrmem, member, NULL_TREE);
 }
 
 /* Given an expression PTR for a pointer, return an expression
@@ -2343,7 +2343,7 @@ get_member_function_from_ptrfunc (tree *
       vtbl = build_indirect_ref (vtbl, NULL);
 
       /* Finally, extract the function pointer from the vtable.  */
-      e2 = fold (build2 (PLUS_EXPR, TREE_TYPE (vtbl), vtbl, idx));
+      e2 = fold_build2 (PLUS_EXPR, TREE_TYPE (vtbl), vtbl, idx);
       e2 = build_indirect_ref (e2, NULL);
       TREE_CONSTANT (e2) = 1;
       TREE_INVARIANT (e2) = 1;



More information about the Gcc-patches mailing list