[cfe-dev] How to use libtooling to parse multiple files at once? and succesfully find stddef.h?

Lukas Vogel lukedirtwalkerdev at gmail.com
Mon Nov 4 04:11:15 PST 2013


This is because clang has some own headers.

Well sourceweb finds the headers because it uses the Clang Path to find the
include directory (I guess).
https://github.com/rprichard/sourceweb/blob/master/clang-indexer/main.cc#L398
(see
the comment there)

You can manually specify the include command (with the -I flag) for each
Source-File in the compile_commands.json file.
In linux the path to the files is something like /usr/lib/clang/3.3/include
or /usr/lib/llvm-3.4/include/clang/

Also look at this:
http://clang.llvm.org/docs/FAQ.html#i-get-errors-about-some-headers-being-missing-stddef-h-stdarg-h

Hope that helps,

Cheers


2013/11/4 rayjcwu <rayjcwu at gmail.com>

> I change my target to gnu tools. Taking wget for example, I could build it
> by
> clang and I use  Bear <https://github.com/rizsotto/Bear>   to generate
> compile_commands.json.
> When I use  my code
> <
> https://github.com/rayjcwu/clang.libtooling.annotator/blob/master/main.cpp
> >
> , which does nothing meanful except visiting, to visit all ast nodes in
> source code, I will get a lot of header files not found error.
> But I could use  sourceweb <https://github.com/rprichard/sourceweb>  ,
> which
> is listed on exteral clang projects, to parse wget with the same .json file
> without any trouble. Even if I change my llvm/clang to version 3.2 the
> error
> still exists.
>
> Is there any quick possible solution for that before I tracing sourceweb
> source code?
>
> ======
> 1 error generated.
> Error while processing /home/jcwu/repos/wget-1.14/src/init.c.
> glthread/threadlib.c:19:10: fatal error: 'config.h' file not found
> #include <config.h>
>          ^
> 1 error generated.
> Error while processing /home/jcwu/repos/wget-1.14/lib/glthread/threadlib.c.
> In file included from ftp-basic.c:32:
> ./wget.h:40:10: fatal error: 'config.h' file not found
> #include "config.h"
>          ^
> 1 error generated.
> Error while processing /home/jcwu/repos/wget-1.14/src/ftp-basic.c.
> futimens.c:19:10: fatal error: 'config.h' file not found
> #include <config.h>
>          ^
> 1 error generated.
> Error while processing /home/jcwu/repos/wget-1.14/lib/futimens.c.
> stripslash.c:19:10: fatal error: 'config.h' file not found
> #include <config.h>
>          ^
> 1 error generated.
> Error while processing /home/jcwu/repos/wget-1.14/lib/stripslash.c.
> dup-safer-flag.c:21:10: fatal error: 'config.h' file not found
> #include <config.h>
>          ^
> 1 error generated.
> Error while processing /home/jcwu/repos/wget-1.14/lib/dup-safer-flag.c.
> In file included from html-parse.c:92:
> ./wget.h:40:10: fatal error: 'config.h' file not found
> #include "config.h"
>          ^
> 1 error generated.
> Error while processing /home/jcwu/repos/wget-1.14/src/html-parse.c.
> In file included from http.c:32:
> ./wget.h:40:10: fatal error: 'config.h' file not found
> #include "config.h"
>          ^
> 1 error generated.
> Error while processing /home/jcwu/repos/wget-1.14/src/http.c.
> In file included from recur.c:32:
> ./wget.h:40:10: fatal error: 'config.h' file not found
> #include "config.h"
>          ^
> 1 error generated.
>
>
>
>
>
> --
> View this message in context:
> http://clang-developers.42468.n3.nabble.com/How-to-use-libtooling-to-parse-multiple-files-at-once-and-succesfully-find-stddef-h-tp4035389p4035587.html
> Sent from the Clang Developers mailing list archive at Nabble.com.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131104/17394706/attachment.html>


More information about the cfe-dev mailing list