Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] finding a function's definition from a call

thank you markus.

i am now on holiday, out of my desk. But I will have a look when coming back .
I hope I will not need to bother you anymore.

meanwhile, I whish you a merry christmass and an happy new year

nicolas


On Thu, Dec 17, 2009 at 7:30 AM, Schorn, Markus
<Markus.Schorn@xxxxxxxxxxxxx> wrote:
> I gave a presentation at EclipseCon 2009:
> 'Using CDT APIs to programmatically introspect C/C++ code'. The slides
> contain some code examples that may help:
> http://wiki.eclipse.org/CDT:Presentations
>
> Markus.
>
>> -----Original Message-----
>> From: cdt-dev-bounces@xxxxxxxxxxx
>> [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Nicolas Anquetil
>> Sent: Wednesday, December 16, 2009 4:45 PM
>> To: cdt-dev@xxxxxxxxxxx
>> Subject: [cdt-dev] finding a function's definition from a call
>> Importance: Low
>>
>> 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
>> _______________________________________________
>> cdt-dev mailing list
>> cdt-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>>
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>



-- 
Nicolas Anquetil        Univ. Lille1 / INRIA-equipe RMod


Back to the top