Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] how do I know where a call will link?

I would try

name.getTranslationUnit().getDefinitions(binding) or
name.getTranslationUnit().getDefinitionsInAST(binding).

The binding is the binding of the 'foo'.
It can be retrievied this way:
IASTExpression nameExpression =
functionCallExpression.getFunctionNameExpression();
IASTName astName = null;
if( nameExpression != null && nameExpression instanceof IASTIdExpression )
{
  astName = ((IASTIdExpression)nameExpression).getName();
}

or with Visitor pattern.

Dmitry

2008/11/25 Jimmie Eriksson <eriksson.jimmie@xxxxxxxxx>:
> If I'm at a IASTFunctionCallExpression in an ASTVisitor, how do I determine
> the function it will be linked to?
> //-----
> file:main.c // the file being ASTvisited
> #include "a.h"
> #include "b.h"
> void main() {
>     foo();    // IASTFunctionCallExpression, (that should be linked to foo()
> in a.c)
> }
> //-----
> file:a.c
> void foo() { // link here...
> }
> //-----
> file:b.c
> static void foo() { // do not link here... as it is static (which means
> invisible..)
> }
> //-----
> The natural way would of course be to check all included files (in the c
> file being visited) and their counterpart .c file for a matching function.
> But I suspect that CDT already have the information available somewhere near
> the IASTFunctionCallExpression? can I somehow use the IASTName below a
> IASTFunctionCallExpression name.resolveBinding(); name.getBinding(); or the
> getScope() ? .. or how do I know where the call will link?
>
> /Jimmie
>
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>
>


Back to the top