Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [cdt-dev] Can't find IASTExpressionList any more more in the CDT AST

Hi,
up to 6.0 the arguments for a function call were returned by IASTFunctionCallExpression.getParameterExpresssion()
like this:
* null, when there is no argument
* IASTExpression for a single argument
* IASTExpressionList for multiple arguments
This API was not the best choice:
* The name is wrong (an argument is not a parameter) .
* It's not obvious and it's not straight forward to figure out how many arguments there are.
* It overloads the meaning of IASTExpressionList, which also represents expressions using the comma-operator.
 
Now in c++0x the argument list for a function call can contain initializer lists, which are no expressions. Therefore,
the argument list can no longer be expressed as an IASTExpression. So, this was a good time to deprecate
IASTFunctionCallExpression.getParameterExpression().
 
While the ast-nodes themselves are backwards compatible in that an IASTExpressionList is created
when you call the deprecated method IASTFunctionCallExpression.getParameterExpression(), a visitor will
follow the new AST-Tree.
 
Markus.
 


From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Beth Tibbitts
Sent: Wednesday, April 21, 2010 11:26 PM
To: CDT General developers list.
Subject: [cdt-dev] Can't find IASTExpressionList any more more in the CDT AST
Importance: Low

I'm debugging some of our PTP static analysis that makes heavy use of the CDT AST APIs.
The original author did a lot of 'instanceof' to discover things.
CDT 7.0 is giving a different behavior than CDT 6.0 did.

A particularly nasty bug now, it turns out, seems to be because a value that comes from a parameter list
isn't populated, probably because as this part of the program is descending down part of the AST,
it expects to find an IASTExpressionList node, and find the parameter in there.
But it never finds it.
In a visitor,
int visitor(IASTExpressions expr){
...
if(expr instanceof IASTExpressionList){ // this is never true
... do something
}
}
I seem to remember some things related to parameters being deprecated,
but IASTExpressionList itself isn't itself deprecated, and I never find one.
Anybody know what I should be looking for instead of this?
AHA.....
If I look at the nodes as they hit the visitor, it sort of looks like
the AST now no longer has an IASTExpressionList node at all.
I see the IASTFunctionCallExpression and then I see the IASTIDExpression for the function name and two UnaryExpressions (one for each arg),
not wrapped in an IASTExpressionList as it was before.

In fact, the DOM AST view shows this quite clearly. Should have looked more closely at (this part of) that sooner.

Nothing like composing a problem for a mailing list post to point the problem out to yourself.
I guess I'll just grab the parameters from the expressions that follow the IASTIDexpression for the call name.

If anyone has more introspection I should be seeing here, please let me know.
I am sort of curious why it changed.



...Beth

Beth Tibbitts
Eclipse Parallel Tools Platform http://eclipse.org/ptp
IBM STG Communications Protocols and Tools
Mailing Address: IBM Corp., Coldstream Research Campus, 745 West New Circle Road, Lexington, KY 40511


Back to the top