[cfe-dev] LibTooling and Header files confirmation

Arnaud Allard de Grandmaison arnaud.adegm at gmail.com
Fri May 2 03:42:10 PDT 2014


On Fri, May 2, 2014 at 12:00 PM, Arnaud Allard de Grandmaison <
arnaud.adegm at gmail.com> wrote:

> Hi David,
>
> On Fri, May 2, 2014 at 5:10 AM, DbdM Tbt <spin.x2k at gmail.com> wrote:
>
>> Good day,
>> I have some aspects I would like confirm about reading header files in
>> the context of LibTooling.
>> My initial idea is that clang, as a compiler framework, mainly 'works
>> with source files'.
>> Header files will come in during pre-processing via the #include
>> directive.
>> But I wanted to see for myself how libtooling works with header files
>> explicitly passed as argument. For this experiment, I used clang-check.
>> Eventually, I came across this question:
>>
>> http://stackoverflow.com/questions/19413156/clang-cant-parse-my-h-file-standalone
>> Confirmation #1: Is there an official documentation/url/FAQ where it is
>> written that clang treats *.h files as C header files?
>>  Or rather, perhaps there is a documentation as to the list of file
>> extensions with the description as to what actions clang will take?
>>
>
> I do not think there is anything specific to clang there.
>
> What is in the header in treated dependingly on the source it was included
> from : you can include a C header from a C++ file. So with a '.h'
> extension, the compiler has to assume it is C. If you use other usual
> extensions (.hpp, ...) then C++ will be assumed. I do not have any pointer
> to some doc/url/faq on top of my head.
>
>
>> Confirmation #2: I tried checking the help for clang-check and I am not
>> sure how to pass an argument similar to "-x c++" to it. Is it possible?
>>
>
> Yes it is possible:
> clang-check yout_header.h -- -x c++
>
> Keep in mind that clang-check makes use of the compilation database, and
> it only contains info for source files, not headers. The syntax above
> allows you to add some options to what was found in the database, or get
> some options eventhough the file was not in the database.
>

Slight mistake there. clang-check uses optionally the compilation database
(when the -p build_path is provided). Using "clang-check your_file --
your_options" will set the flags to use, irrespective of the use of
compilation database or not.


>
> Confirmation #3: Is there a 'correct' approach with regards to libtooling
>> and handling header files? I am planning on ignoring header files passed to
>> my libtool.
>>
>
> It all depends on your application.
>
>
>> Hoping for your insights.
>> Thank you,
>> David
>>
>>
>> _______________________________________________
>> 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/20140502/8be6fea8/attachment.html>


More information about the cfe-dev mailing list