[Cdt-l] finding a function's definition from a call
Nicolas Anquetil
anquetil.nicolas at gmail.com
Wed Dec 16 06:56:26 CST 2009
Hi,
This is certainly a basic question but I cannot seem to find clear
information on the net.
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
--
Nicolas Anquetil Univ. Lille1 / INRIA-equipe RMod
More information about the Cdt-l
mailing list