[Cdt-l] finding a function's definition from a call

Jonathan Ley jonathan at phlumf.com
Wed Dec 16 14:26:51 CST 2009


To answer your question: Yes, you can analyze C programs using the CDT. 
You'll have lots of quiet time to contemplate such questions, and clear 
your head of all the clutter that is probably obfuscating the answers 
you seek. However, using the CDT for such a thing can take a while... 
maybe up to 5 months to get an answer. And even when you're done, you 
might have to use other tools like the AT and PCT to do some comparison 
with the CDT results. To answer some other questions you might have...

-  Water is not as much of a problem as you might think, you just have 
to plan...
-  Pick any route you want in southern NM, they're all good.
-  Most people say the most dramatic scenery is in the Winds
-  The Big Sandy situation is a bummer... but if you make a reservation 
to stay there, they'll hold a package for you
-  You do need permits in Yellowstone & Glacier, but the process isn't 
so bad... as long as you can stand watching their "bear videos".
-  It depends on the snowpack
-  June 15th

I haven't heard of the AST... where does that go?

Good luck out there!


Nicolas Anquetil wrote:
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.backcountry.net/pipermail/cdt-l/attachments/20091216/4ba8819b/attachment.html 

More information about the Cdt-l mailing list