[cfe-users] Getting function body from AST for interprocedural analysis

George Karpenkov via cfe-users cfe-users at lists.llvm.org
Fri Mar 23 15:25:42 PDT 2018

Hi Lauro,

I think you would have more luck  asking on cfe-dev mailing list.
Do I understand your question correctly as wishing to do cross-translation-unit analysis?
Clang static analyzer has an experimental flag for doing that, which relies on ASTImporter library
(which tries to import AST for all included C++ files).
However, that library is known to be very brittle.

(of course if by other files you mean other *header* files, not the C++ files, then everything is much simpler,
and you should be able to get the AST from clang directly)

> On Mar 14, 2018, at 7:39 PM, Lauro Cruz via cfe-users <cfe-users at lists.llvm.org> wrote:
> Good Evening!
> I'm playing a little with Clang and I'm trying to do a sort of
> interprocedural def-use analysis in the clang AST and I need to visit
> the body of functions not defined in the current file.
> I've been searching a way to do that and I see there is something to
> do with Libtooling, but I can't figure out how. I see there is a
> function in ClangTool called BuildASTs, but for that I need to
> instantiate a CommomOptionsParser with the command line arguments,
> which I don't have in the CodeGen file I'm working.
> Can someone give me a light on how I can build the ASTs with the
> funciton definitions and get this definition from the ASTs?
> Thanks!
> -- 
> Lauro Cruz e Souza
> Computer Engineering BSc- 2014
> State University of Campinas (UNICAMP)
> +55 19 99857-6981
> Facebook: lcruzsouza | Github: laurocruz
> _______________________________________________
> cfe-users mailing list
> cfe-users at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users

More information about the cfe-users mailing list