Siddharth Shankar Swain via llvm-dev
2017-Sep-14 13:57 UTC
[llvm-dev] Dependency Info from AST
Hi, Can anyone help if for example we have multiple c files and we want to analyze their ASTs to find out any dependency between them ( like a function defined in one c file is used in other, any external variable etc ). How can we do it at the AST level? I mean is there any automated tool or flag for it in LLVM. If anyone has any idea please tell. sincerely, Siddharth -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170914/2b8d6282/attachment.html>
(Apologies for the re-send Siddharth, I failed to cc the list) There is no existing tool that I'm aware of which performs this analysis on the AST. It is possible to do on an AST. You would just need to write an AST Visitor that finds declarations, definitions, and uses of functions. Is there a reason you need to do this at the AST level? With C code this analysis can be trivially performed with `nm` on the object files, so if you don't have a strong reason for needing to do this on the AST I'd just write a script to wrap `nm` rather than writing an AST Visitor. -Chris> On Sep 14, 2017, at 6:57 AM, Siddharth Shankar Swain via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hi, > Can anyone help if for example we have multiple c files and we want to analyze their ASTs to find out any dependency between them ( like a function defined in one c file is used in other, any external variable etc ). How can we do it at the AST level? I mean is there any automated tool or flag for it in LLVM. If anyone has any idea please tell. > sincerely, > Siddharth > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Siddharth Shankar Swain via llvm-dev
2017-Sep-19 17:09 UTC
[llvm-dev] Dependency Info from AST
Hi Chris, Thanks for the suggestion i was trying to use the patch https://reviews.llvm.org/D30691 and ASTimporter concept for cross file analysis. Can u explain in details the approach u suggested ? What is `nm` on the object files ? Can u suggest some approach to start on this cross file analysis tool. Thanks, Siddharth On Tue, Sep 19, 2017 at 9:42 PM, Chris Bieneman <beanz at apple.com> wrote:> (Apologies for the re-send Siddharth, I failed to cc the list) > > There is no existing tool that I'm aware of which performs this analysis > on the AST. It is possible to do on an AST. You would just need to write an > AST Visitor that finds declarations, definitions, and uses of functions. > > Is there a reason you need to do this at the AST level? With C code this > analysis can be trivially performed with `nm` on the object files, so if > you don't have a strong reason for needing to do this on the AST I'd just > write a script to wrap `nm` rather than writing an AST Visitor. > > -Chris > > > On Sep 14, 2017, at 6:57 AM, Siddharth Shankar Swain via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > > > > Hi, > > Can anyone help if for example we have multiple c files and we want to > analyze their ASTs to find out any dependency between them ( like a > function defined in one c file is used in other, any external variable etc > ). How can we do it at the AST level? I mean is there any automated tool or > flag for it in LLVM. If anyone has any idea please tell. > > sincerely, > > Siddharth > > _______________________________________________ > > LLVM Developers mailing list > > llvm-dev at lists.llvm.org > > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170919/f175e06d/attachment.html>