[lto] cp/method.c: Introduce num_artificial_parms_for.

Kazu Hirata kazu@codesourcery.com
Mon Jun 19 01:55:00 GMT 2006


Hi,

Attached is a patch to introduce num_artificial_parms_for.

Consider the definition of FUNCTION_FIRST_USER_PARMTYPE.

#define FUNCTION_FIRST_USER_PARMTYPE(NODE) \
  skip_artificial_parms_for ((NODE), TYPE_ARG_TYPES (TREE_TYPE (NODE)))

Since skip_artificial_parms_for uses TREE_CHAIN, we are effectively
using TREE_CHAIN on TYPE_ARG_TYPES.  Since we eventually want to
convert TYPE_ARG_TYPES to use TREE_VEC, we cannot use TREE_CHAIN.  We
have to deal with indexes into a TREE_VEC instead.

This patch introduces num_artificial_parms_for to facilitate index
manipulation.  This patch itself does not add any use of the new
function.

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

Kazu Hirata

2006-06-19  Kazu Hirata  <kazu@codesourcery.com>

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

Index: cp/cp-tree.h
===================================================================
--- cp/cp-tree.h	(revision 114740)
+++ cp/cp-tree.h	(working copy)
@@ -4069,6 +4069,7 @@ extern void synthesize_method			(tree);
 extern tree lazily_declare_fn			(special_function_kind,
 						 tree);
 extern tree skip_artificial_parms_for		(tree, tree);
+extern int num_artificial_parms_for		(tree);
 extern tree make_alias_for			(tree, tree);
 
 /* In optimize.c */
Index: cp/method.c
===================================================================
--- cp/method.c	(revision 114740)
+++ cp/method.c	(working copy)
@@ -1180,4 +1180,24 @@ skip_artificial_parms_for (tree fn, tree
   return list;
 }
 
+/* Given a FUNCTION_DECL FN and a chain LIST, return the number of
+   artificial parms in FN.  */
+
+int
+num_artificial_parms_for (tree fn)
+{
+  int count = 0;
+
+  if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fn))
+    count++;
+  else
+    return 0;
+
+  if (DECL_HAS_IN_CHARGE_PARM_P (fn))
+    count++;
+  if (DECL_HAS_VTT_PARM_P (fn))
+    count++;
+  return count;
+}
+
 #include "gt-cp-method.h"



More information about the Gcc-patches mailing list