[cfe-dev] How to execute clang front-end AST visitor to exract some information from source code without compiling the source code first
David Blaikie via cfe-dev
cfe-dev at lists.llvm.org
Tue Jul 12 08:34:54 PDT 2016
You should be using a compilation database with your tooling application to
retrieve/use the matching compilation commands for your project, that
should include any header search paths, etc. CMake can generate such a
database, so if the project you're trying to build has cmake support, this
might be an option. Otherwise you may need to teach a build system about it.
(probably the most generic thing someone could build to help here would be
a scan-build like build-interposition tool to make a compilation database
from any project/build system. Not the most efficient, but would be handy
as a fallback)
On Tue, Jul 12, 2016 at 5:47 AM, Georgiou, Andreas via cfe-dev <
cfe-dev at lists.llvm.org> wrote:
> Hello all,
> For my project I have develop a resursive AST visitor which reates the AST
> from a give source files and its included header files and extracts some
> information from source code such as declared function names and types,
> declared variable types and names and function calls. It takes a .cpp
> source file as input and parses the file and finds all the nescessary
> information I need to.
> The thing is if a try to analyse a project such as LIBTIFF or FFMPEG, it
> gets me all sort of errors such as undeclared identifiers and missing
> header files.
> Is there a way to execute this front-end tool without making it compile
> the code first? I assume the code is correclty syntaxed though. My
> front-end tool is called in tin this way:
> // parse the command-line args passed to your code
> CommonOptionsParser op(argc, argv);
> // create a new Clang Tool instance (a LibTooling environment)
> ClangTool Tool(op.getCompilations(), op.getSourcePathList());
> // run the Clang Tool, creating a new FrontendAction (explained below)
> int result =
> Is there a way? Maybe a compiler argument or something??
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev