* help:how to get the Nth argument stmt from CALL_EXPR stmt tree
@ 2005-07-05 15:19 alert7
2005-07-05 22:41 ` Daniel Berlin
0 siblings, 1 reply; 2+ messages in thread
From: alert7 @ 2005-07-05 15:19 UTC (permalink / raw)
To: gcc
hi,all
I don't know how to get the Nth argument stmt from CALL_EXPR stmt tree?
the GetCallArgOperands implement this function that i code ,but it isn't working :(
thanks any advice or piece of example code .
//////////////////////////////////////////////////////
tree GetCallArgOperands(tree stmt ,int i){
tree func, param, args;
int j = 1;
func = get_callee_fndecl (stmt);
for (param = DECL_ARGUMENTS (func), args = TREE_OPERAND (stmt, 1);
param && args;
param = TREE_CHAIN (param), args = TREE_CHAIN (args))
{
tree arg = TREE_VALUE (args);
if (param != arg)
{
// FIXME:
}
if (j==i)
{
fprintf(stderr,"args ----------\n");
debug_tree(arg);
return default_def (arg); //FIXME: to stmt tree ?
}
j++;
}
return NULL_TREE;
}
/////////////////////////////////////////////////
bugs
bugs@whitecell.org
2005-07-05
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: help:how to get the Nth argument stmt from CALL_EXPR stmt tree
2005-07-05 15:19 help:how to get the Nth argument stmt from CALL_EXPR stmt tree alert7
@ 2005-07-05 22:41 ` Daniel Berlin
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Berlin @ 2005-07-05 22:41 UTC (permalink / raw)
To: alert7; +Cc: gcc
On Tue, 2005-07-05 at 23:18 +0800, alert7 wrote:
> hi,all
>
>
> I don't know how to get the Nth argument stmt from CALL_EXPR stmt tree?
assuming TREE_CODE (call) == CALL_EXPR:
GetCallArgOperand(tree call, int i)
{
int j = 0;
tree arg;
for (arg = TREE_OPERAND (call, 1); arg; arg = TREE_CHAIN (arg), j++)
{
if (i == j)
return TREE_VALUE (arg);
}
}
>
> the GetCallArgOperands implement this function that i code ,but it isn't working :(
You are looking at the arguments the declaration takes, instead of the
arguments passed to the function.
Arguments passed to the function are stored in TREE_OPERAND (call, 1),
as tree.def says.
>
> thanks any advice or piece of example code .
>
> //////////////////////////////////////////////////////
>
> tree GetCallArgOperands(tree stmt ,int i){
> tree func, param, args;
> int j = 1;
>
>
> func = get_callee_fndecl (stmt);
>
> for (param = DECL_ARGUMENTS (func), args = TREE_OPERAND (stmt, 1);
> param && args;
> param = TREE_CHAIN (param), args = TREE_CHAIN (args))
> {
> tree arg = TREE_VALUE (args);
> if (param != arg)
> {
> // FIXME:
> }
> if (j==i)
> {
> fprintf(stderr,"args ----------\n");
> debug_tree(arg);
>
> return default_def (arg); //FIXME: to stmt tree ?
> }
>
> j++;
> }
> return NULL_TREE;
> }
> /////////////////////////////////////////////////
>
>
>
>
>
> bugs
> bugs@whitecell.org
> 2005-07-05
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-07-05 22:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-05 15:19 help:how to get the Nth argument stmt from CALL_EXPR stmt tree alert7
2005-07-05 22:41 ` Daniel Berlin
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).