* [PATCH] remove TYPE_ARG_TYPES from godump.c
@ 2011-05-20 14:44 Nathan Froyd
2011-05-20 20:36 ` Ian Lance Taylor
0 siblings, 1 reply; 2+ messages in thread
From: Nathan Froyd @ 2011-05-20 14:44 UTC (permalink / raw)
To: gcc-patches; +Cc: iant
As $SUBJECT suggests. It may be worth noting that we now do more work
after this patch (stdarg_p and prototype_p both traverse TYPE_ARG_TYPES
under the hood); one day those will be simple boolean tests.
Tested on x86_64-unknown-linux-gnu with go. OK to commit?
-Nathan
gcc/
* godump.c (go_format_type): Don't use TYPE_ARG_TYPES.
diff --git a/gcc/godump.c b/gcc/godump.c
index 16a4803..c4557f8 100644
--- a/gcc/godump.c
+++ b/gcc/godump.c
@@ -741,9 +741,11 @@ go_format_type (struct godump_container *container, tree type,
case FUNCTION_TYPE:
{
- tree args;
+ tree arg_type;
bool is_varargs;
tree result;
+ function_args_iterator iter;
+ bool seen_arg = false;
/* Go has no way to write a type which is a function but not a
pointer to a function. */
@@ -754,25 +756,20 @@ go_format_type (struct godump_container *container, tree type,
}
obstack_1grow (ob, '(');
- is_varargs = true;
- for (args = TYPE_ARG_TYPES (type);
- args != NULL_TREE;
- args = TREE_CHAIN (args))
+ is_varargs = stdarg_p (type);
+ FOREACH_FUNCTION_ARGS (type, arg_type, iter)
{
- if (VOID_TYPE_P (TREE_VALUE (args)))
- {
- gcc_assert (TREE_CHAIN (args) == NULL);
- is_varargs = false;
- break;
- }
- if (args != TYPE_ARG_TYPES (type))
+ if (VOID_TYPE_P (arg_type))
+ break;
+ if (seen_arg)
obstack_grow (ob, ", ", 2);
- if (!go_format_type (container, TREE_VALUE (args), true, false))
+ if (!go_format_type (container, arg_type, true, false))
ret = false;
+ seen_arg = true;
}
if (is_varargs)
{
- if (TYPE_ARG_TYPES (type) != NULL_TREE)
+ if (prototype_p (type))
obstack_grow (ob, ", ", 2);
obstack_grow (ob, "...interface{}", 14);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] remove TYPE_ARG_TYPES from godump.c
2011-05-20 14:44 [PATCH] remove TYPE_ARG_TYPES from godump.c Nathan Froyd
@ 2011-05-20 20:36 ` Ian Lance Taylor
0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2011-05-20 20:36 UTC (permalink / raw)
To: Nathan Froyd; +Cc: gcc-patches
Nathan Froyd <froydnj@codesourcery.com> writes:
> gcc/
> * godump.c (go_format_type): Don't use TYPE_ARG_TYPES.
> case FUNCTION_TYPE:
> {
> - tree args;
> + tree arg_type;
> bool is_varargs;
> tree result;
> + function_args_iterator iter;
> + bool seen_arg = false;
>
> /* Go has no way to write a type which is a function but not a
> pointer to a function. */
> @@ -754,25 +756,20 @@ go_format_type (struct godump_container *container, tree type,
> }
>
> obstack_1grow (ob, '(');
> - is_varargs = true;
> - for (args = TYPE_ARG_TYPES (type);
> - args != NULL_TREE;
> - args = TREE_CHAIN (args))
> + is_varargs = stdarg_p (type);
> + FOREACH_FUNCTION_ARGS (type, arg_type, iter)
Please move the initialization of seen_arg to down just before the
loop. I find it harder to have to look back up to the definition to
verify that the loop runs correctly.
This is OK with that change.
Thanks.
Ian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-05-20 17:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-20 14:44 [PATCH] remove TYPE_ARG_TYPES from godump.c Nathan Froyd
2011-05-20 20:36 ` Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).