The last remaining uses of build_function_type in the ObjC/C++ frontends
comes from this pattern:
tree method_param_types =
get_arg_type_list (method_prototype, METHOD_REF, super_flag);
tree ftype = build_function_type (ret_type, method_param_types);
To eliminate this, I made the following changes:
- Package the above pattern up into a function,
build_function_type_for_method. This change meant that
get_arg_type_list didn't need to exist as a separate function, so I
made get_arg_type_list go away.
- To make build_function_type_for_method call build_function_type_vec, I
needed to change the interface to the runtime hook function
get_arg_type_list_base: it now takes a VEC to which it appends the
necessary arguments. build_function_type_for_method then appends the
appropriate arguments and builds the new function type.
- However, the NeXT v2 ABI method call builder used the type list
returned by get_arg_type_list separately, passing it to
objc_copy_to_temp_side_effect_params. I therefore changed that
function to consult the newly built function type instead, using an
iterator.
I also adjust the header comments to reflect the new world order and
wrapped them to 80 columns where appropriate.
Tested on x86_64-unknown-linux-gnu, ObjC/C++ testsuites. I will fix any
Darwin breakage that comes up, though I may need some debugging help to
do so. OK to commit?
-Nathan
gcc/objc/
* objc-runtime-shared-support.h (get_arg_type_list): Delete.
(build_function_type_for_method): Declare.
* objc-runtime-hooks.h (struct _objc_runtime_hooks_r): Change
type of get_arg_type_base_list field.
* objc-act.h (OBJC_VOID_AT_END): Delete.
* objc-act.c (get_arg_type_list): Delete.
(build_function_type_for_method): New function.
(objc_decl_method_attributes): Call build_function_type_for_method.
(really_start_method): Likewise.
* objc-gnu-runtime-abi-01.c
(gnu_runtime_abi_01_get_type_arg_list_base): Change prototype and
adjust function accordingly. Update header comment.
(build_objc_method_call): Call build_function_type_for_method.
* objc-next-runtime-abi-01.c
(next_runtime_abi_01_get_type_arg_list_base): Change prototype and
adjust function accordingly. Update header comment.
(build_objc_method_call): Call build_function_type_for_method.
* objc-next-runtime-abi-02.c
(next_runtime_abi_02_get_type_arg_list_base): Change prototype and
adjust function accordingly. Update header comment.
(objc_copy_to_temp_side_effect_params): Take fntype instead of a
typelist. Use function_args_iterator for traversing fntype.
(build_v2_build_objc_method_call): Adjust call to it.
Call build_function_type_for_method
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 025f375..e3de6db 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -5040,8 +5040,9 @@ objc_decl_method_attributes (tree *node, tree attributes,
int flags)
(by setting TREE_DEPRECATED and TREE_THIS_VOLATILE) so there
is nothing to do. */
tree saved_type = TREE_TYPE (*node);
- TREE_TYPE (*node) = build_function_type
- (TREE_VALUE (saved_type), get_arg_type_list (*node, METHOD_REF, 0));
+ TREE_TYPE (*node)
+ = build_function_type_for_method (TREE_VALUE (saved_type), *node,
+ METHOD_REF, 0);
decl_attributes (node, filtered_attributes, flags);
METHOD_TYPE_ATTRIBUTES (*node) = TYPE_ATTRIBUTES (TREE_TYPE (*node));
TREE_TYPE (*node) = saved_type;
@@ -5054,60 +5055,66 @@ objc_method_decl (enum tree_code opcode)
return opcode == INSTANCE_METHOD_DECL || opcode == CLASS_METHOD_DECL;
}
-/* Used by `build_objc_method_call'. Return an argument list for
- method METH. CONTEXT is either METHOD_DEF or METHOD_REF, saying
- whether we are trying to define a method or call one. SUPERFLAG
- says this is for a send to super; this makes a difference for the
- NeXT calling sequence in which the lookup and the method call are
- done together. If METH is null, user-defined arguments (i.e.,
- beyond self and _cmd) shall be represented by `...'. */
+/* Return a function type for METHOD with RETURN_TYPE. CONTEXT is
+ either METHOD_DEF or METHOD_REF, indicating whether we are defining a
+ method or calling one. SUPER_FLAG indicates whether this is a send
+ to super; this makes a difference for the NeXT calling sequence in
+ which the lookup and the method call are done together. If METHOD is
+ NULL, user-defined arguments (i.e., beyond self and _cmd) shall be
+ represented as varargs. */
tree
-get_arg_type_list (tree meth, int context, int superflag)
+build_function_type_for_method (tree return_type, tree method,
+ int context, bool super_flag)
{
- tree arglist, akey;
+ VEC(tree,gc)