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

Laszlo Nagy via cfe-dev cfe-dev at lists.llvm.org
Wed Jul 13 05:45:40 PDT 2016


@Georgiou, when you generate a compilation database, it's better to
validate it with other tools. you can run `clang-check`, `clang-format`
just to see it's valid. if it is and your tool still fails with include
problems, it might be the reason
<http://clang.llvm.org/docs/LibTooling.html#builtin-includes> mentioned in
the tooling doc. the other thing i noticed, that you use relative path to
the module. (instead of `
../ffmpeg-0.6/libavcodec/libxvid_rc.c` try
`/home/andreas/Desktop/ffmpeg-0.6/libavcodec/libxvid_rc.c`)

@David, the `build-interposition` command is already in the Clang source
repo. it's in `tools/scan-build-py/bin` called `intercept-build`.


regards,
Laszlo

On Wed, Jul 13, 2016 at 9:10 PM, Georgiou, Andreas via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hi all,
>
>
> As Miklos pointed out I am using Bear to create a compilation database to
> analyze my source code. This lead to much better results.
>
> Although I still have some problems. Does anyone knows why this happens?
>
>
> When I am executing using the compilation database I get this error on
> certain files:
>
> Executing ASTvisitor ../ffmpeg-0.6/libavcodec/libxvid_rc.c
> Skipping
> /home/andreas/Desktop/test_analysis/../ffmpeg-0.6/libavcodec/libxvid_rc.c.
> Command line not found.
>
> And does  not extract anything from the file.
>
> When am executing myAST visitor with the exact same file but without the
> compilation database it gives me the error:
>  'xvid.h' file not found
>
> but it analyses the file and the results are mostly correct. The visitor
> skips enything which has to do with variable declarations of the xvid.h
> header.
> "How can the command line not found" error can be fixed?
>
> Thank you all.
>
> ------------------------------
> *From:* Miklos Vajna <vmiklos at vmiklos.hu>
> *Sent:* 12 July 2016 20:06:46
> *To:* David Blaikie
> *Cc:* Georgiou, Andreas; cfe-dev at lists.llvm.org
> *Subject:* Re: [cfe-dev] How to execute clang front-end AST visitor to
> exract some information from source code without compiling the source code
> first
>
> Hi,
>
> On Tue, Jul 12, 2016 at 08:34:54AM -0700, David Blaikie via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
> > (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)
>
> This is exactly what <https://github.com/rizsotto/Bear> implements.
>
> Regards,
>
> Miklos
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160713/10c9d158/attachment.html>


More information about the cfe-dev mailing list