[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-dev] finding a function's definition from a call
|
Hi,
This is certainly a basic question but I cannot seem to find clear
information on the net (I even asked by mistake on cdt-l, the
Continental Divide Trail mailing list, whatever it is ... :) ).
I want to analyse some C program using CDT.
When I find in the AST an IASTExpression that I know is a function
call (instanceof IASTFunctionCallExpression), how can I find where the
function is defined (in what file) ?
I am experimenting with a simple C project that has 2 files and one
function in each file, one of the functions calls the other.
I could access the name of the FunctionCall and from that the IBinding.
What next?
I tried expr.getTranslationUnit().getDefinitionsInAST(name.resolveBinding())
with either file as translationUnit but that gave me an empty array
:-(
May be it comes from how I generate the AST?
ICProject cproj = CoreModel.getDefault().create(proj);
for (ICContainer folder : cproj.getSourceRoots()) {
for (ITranslationUnit unit : folder.getTranslationUnits()) {
IASTTranslationUnit unitAST = unit.getAST();
[...then explore the AST 'unitAST' to find
IASTFunctionCallExpression in it ... ]
Can you help?
Please?
--
Nicolas Anquetil Univ. Lille1 / INRIA-equipe RMod