Certain idioms are ignored by -Wunused in header files only.
The current "is a header" check assumes that if headers are the main file, we're
building a PCH or a module or something. However in tools we may be parsing the
header in its own right, but still want to treat it as a header.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
It's possible we should *only* be checking the IsHeaderFile flag here and drop all the sourcemanager stuff, but I'm not sure of the implications - thoughts appreciated.
clang/lib/Sema/SemaDecl.cpp | ||
---|---|---|
1784 | i think we can just bail out early here when the main file is a header file (i.e. lang opts have IsHeaderFile set). |
As discussed offline this idea doesn't make sense. LangOpts tells us about the main file, so we still need to check that it's in the main file for that to be relevant.
clang/lib/Sema/SemaDecl.cpp | ||
---|---|---|
1784 | This makes sense. I'd rather do this as a separate commit in case we need to revert. (This function isn't terribly hot in the clangd profiles I have, but seems like a reasonable change to me anyway) |
clang/lib/Sema/SemaDecl.cpp | ||
---|---|---|
1784 | SG. i was actually worried about the behaviour implied by the name "isMainFileLoc". i feel like both TU_Complete and IsHeaderFile check should actually happen here (or at least outside of the isMainFileLoc). |
i think we can just bail out early here when the main file is a header file (i.e. lang opts have IsHeaderFile set).