[cfe-dev] How to execute clang front-end AST visitor to exract some information from source code without compiling the source code first

Georgiou, Andreas via cfe-dev cfe-dev at lists.llvm.org
Tue Jul 12 05:47:00 PDT 2016


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 = Tool.run(newFrontendActionFactory<ExampleFrontendAction>());

Is there a way? Maybe a compiler argument or something??


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160712/3d467f03/attachment.html>


More information about the cfe-dev mailing list