[cfe-dev] Check if inside a header file

Jordan Rose jordan_rose at apple.com
Fri Jan 17 17:49:30 PST 2014


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/20140117/5feca1a0/attachment.html>


More information about the cfe-dev mailing list