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]

[lto] Introduce new function build_type_list_by_dropping.


Hi,

Attached is a patch to introduce new function
build_type_list_by_dropping.

In certain places in the C++ frontend, we drop the first type of the
parameter list and then pass the remaining list to build a new
function type like so:

      from = build_method_type_directly (from,
					 TREE_TYPE (fromfn),
					 TREE_CHAIN (TYPE_ARG_TYPES (fromfn)));

In order to facilitate this type of parameter list construction, the
patch adds a new function that takes an existing parameter list and
returns a new parameter list identical to the existing one with the
first N parameter types dropped.

For simplicity, I am not adding any use of the new function.

Tested on x86_64-pc-linux-gnu.  OK to apply to the LTO branch?

Kazu Hirata

2006-08-07  Kazu Hirata  <kazu@codesourcery.com>

	* tree.c (build_type_list_by_dropping): New.
	* cp-tree.h: Add a prototype for build_type_list_by_dropping.

Index: cp/cp-tree.h
===================================================================
--- cp/cp-tree.h	(revision 115969)
+++ cp/cp-tree.h	(working copy)
@@ -4390,6 +4390,7 @@ extern tree fold_if_not_in_template		(tr
 extern tree rvalue                              (tree);
 extern tree convert_bitfield_to_declared_type   (tree);
 extern tree cp_save_expr                        (tree);
+extern tree build_type_list_by_dropping		(tree, int);
    
 /* in typeck.c */
 extern int string_conv_p			(tree, tree, int);
Index: cp/tree.c
===================================================================
--- cp/tree.c	(revision 115969)
+++ cp/tree.c	(working copy)
@@ -2355,6 +2355,24 @@ fold_if_not_in_template (tree expr)
   return fold (expr);
 }
 
+/* Build a new type list by dropping the first N types from
+   PARM_TYPES.  */
+
+tree
+build_type_list_by_dropping (tree parm_types, int n)
+{
+  int len = num_parm_types (parm_types);
+  VEC(tree,heap) *v = VEC_alloc (tree, heap, len - n);
+  int i;
+
+  for (i = 0; i < len - n; i++)
+    VEC_quick_push (tree, v, nth_parm_type (parm_types, n + i));
+
+  parm_types = vec_heap2parm_types (v);
+  VEC_free (tree, heap, v);
+  return parm_types;
+}
+
 
 #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
 /* Complain that some language-specific thing hanging off a tree


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