[cfe-dev] Check if inside a header file

Nikola Smiljanic popizdeh at gmail.com
Fri Jan 17 23:48:28 PST 2014


I was actually looking at this
http://llvm.org/bugs/show_bug.cgi?id=16686but it seems that there's no
way to fix this. I understand that compiler
doesn't care, but I was hoping that this information was stored somewhere
(at least based on file extension). Any other ideas?


On Sat, Jan 18, 2014 at 12:49 PM, Jordan Rose <jordan_rose at apple.com> wrote:

> Oh. Not if we infer that from .h or .hxx, because then a lot of existing
> use cases will break. I guess that does call for a new predicate, then.
>
> On Jan 17, 2014, at 17:48, Richard Smith <metafoo at gmail.com> wrote:
>
> Perhaps isInMainFile should return false if the file type was specified as
> -x c-header or -x c++-header?
>
> On Fri Jan 17 2014 at 5:42:22 PM, Jordan Rose <jordan_rose at apple.com>
> wrote:
>
>> There's not actually any difference between a header file passed as a
>> main file and a normal main file. C doesn't care that one has a .h and/or
>> lives in your include/ folder and that the other has a .c and/or lives in
>> src/ or lib/. I think you've just got to accept that.
>>
>> Jordan
>>
>>
>> On Jan 17, 2014, at 16:50, Nikola Smiljanic <popizdeh at gmail.com> wrote:
>>
>> > Is there a way to know if I'm inside a header file in the Preprocessor
>> class. I've only been able to find warn_using_directive_in_header that does
>> a similar check, only to realize that it's not 100% correct. It uses
>> SourceMgr.isInMainFile which is not right if you pass a header file
>> directly, no warning is generated in that case.
>> > _______________________________________________
>> > cfe-dev mailing list
>> > cfe-dev at cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>> _______________________________________________
>> 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/20140118/0aee7df7/attachment.html>


More information about the cfe-dev mailing list