[cfe-dev] Retrieving Appropriate Headers

Pedro Delgado Perez pedro.delgadoperez at mail.uca.es
Tue May 13 10:54:39 PDT 2014


 
Hi again,

Maybe this is what I was looking for:

http://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-in-system-headers [ http://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-in-system-headers ]

But, how can I put into practice when creating a tool instead of directly running the command clang?


> Hi,
> Regarding the problem I exposed, I found the next tutorial:
> https://github.com/loarabia/Clang-tutorial/blob/master/tutorial6.cpp [ https://github.com/loarabia/Clang-tutorial/blob/master/tutorial6.cpp ]
> In that tutorial, they use the option:
> 
> headerSearchOptions->AddPath("/usr/include/linux",
> clang::frontend::Angled,
> false, false);
> But:
> 1- I don't know if this is what I'm looking for (how could my tool know that a header file like "<name_x/file.h> is in a path which does not even has the directory "name_x" in it?)
> 2- I don't know how can I adapt this code to my tool, as I don't use anything similar to:
> clang::ParseAST(preprocessor,&astConsumer,astContext);
> Can anyone give me a clue to solve this?
> 
> Hi,
> 
> Some C++ programs include headers which are not in the same directory as the file being processed. In some cases, it is used a path relative to the file, for instance "directory/file.h". And in some other cases, the headers are included in a way understandable to the build system of the program, even using angled headers "<name/file.h> and that path is not relative to its location. 
> The problem for me is that I don't know how can I indicate in my tool the exact location of headers which are not in the same directory when creating the AST.
> I'm using something like this to parse the code:
>  ...
>  ClangTool Tool(OptionsParser.getCompilations(), file); 
>  Tool.run(newFrontendActionFactory(&mytool));
> ...
> 
> so I would need to tell the object "Tool" to find also in other directories, for instance, a mapping of the headers included and their directory. Or is there a simple way to do this that I'm overlooking?
> 
> Thanks,
> Pedro.
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140513/3ab9c8ff/attachment.html>


More information about the cfe-dev mailing list