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.
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.
Perhaps isInMainFile should return false if the file type was specified as -x c-header or -x c+±header?
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.
I was actually looking at this http://llvm.org/bugs/show_bug.cgi?id=16686 but 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?
Eli’s comment in the bug report gave me the impression that this needs fixing… Is that the case or should we just close this bug?