Remove lots of useless/misplaced includes#7999
Conversation
|
For reference: For zyn we have planned an action which greps for these unnecessary includes, and here is example output of the job. |
7fb1853 to
2ca0889
Compare
7ceb7e2 to
59a6359
Compare
Follow-Up of 7db3fa9 . This was done by setting `CMAKE_C_INCLUDE_WHAT_YOU_USE` and `CMAKE_CXX_INCLUDE_WHAT_YOU_USE` to (broken down into multiple lines here, note, all below `FL/x.h` is not required for C): ``` include-what-you-use; -Xiwyu;--mapping_file=/usr/share/include-what-you-use/qt5_11.imp; -Xiwyu;--keep=*/xmmintrin.h; -Xiwyu;--keep=*/lmmsconfig.h; -Xiwyu;--keep=*/weak_libjack.h; -Xiwyu;--keep=*/sys/*; -Xiwyu;--keep=*/debug.h; -Xiwyu;--keep=*/SDL/*; -Xiwyu;--keep=*/alsa/*; -Xiwyu;--keep=*/FL/x.h; -Xiwyu;--keep=*/MidiApple.h; -Xiwyu;--keep=*/MidiWinMM.h; -Xiwyu;--keep=*/AudioSoundIo.h; -Xiwyu;--keep=*/OpulenZ/adplug/*; -Xiwyu;--keep=QPainterPath; -Xiwyu;--keep=QtTest ``` FAQ: * Q: Does this speed-up a completely fresh compile? * A: No, I measured it. * Q: Does it speed up anything else? * A: Yes. If you change one header, it can reduce the number of CPP files that your compiler needs to recompile, or your IDE has to re-scan. * Q: What other reasons are for this PR? * A: It's idiomatic to only include headers if you need them. Also, it will reduce output for those who want to use IWYU for new PRs. Background: This is just a remainder PR of what I planned. My original idea was to setup a CI which warns you of useless includes (but not of all issues that IWYU complains about). However, I could not see that this was favored on Discord. A full IWYU CI also has the problem that it (possibly??) needs to compile with `make -j 1`, which would make CI really slow. However, for that plan, I had to fix the whole code base to be IWYU compliant - which it now is.
allejok96
left a comment
There was a problem hiding this comment.
Nice housekeeping. I just glanced through it. If it builds it works™
| #include <QString> | ||
|
|
||
| #include "lmms_export.h" | ||
| #ifdef PLUGIN_NAME |
There was a problem hiding this comment.
What does this have to do with IWYU? just curious, not even trying
There was a problem hiding this comment.
LmmsCommonMacros.h only defines two macros: LMMS_STR and LMMS_STRINGIFY. Both are used in embed.h only if PLUGIN_NAME is defined. So the change seems sane.
My guess why I did this: I probably compiled a CPP file which include embed.h while PLUGIN_NAME was undefined - so IWYU likely told me: "You're including that header, but in this translation unit, you are not using anything from that header" - so I wrapped the #if around the include to make IWYU happy.
|
This PR still need one approval of a reviewer with write access. I guess this should be easy to finish, after 2 devs have already reviewed? |
Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
Follow-Up of 7db3fa9 .
This was done by setting
CMAKE_C_INCLUDE_WHAT_YOU_USEandCMAKE_CXX_INCLUDE_WHAT_YOU_USEto (broken down into multiple lines here, note, all belowFL/x.his not required for C):FAQ:
Q: Does this speed-up a completely fresh compile?
A: No, I measured it.
Q: Does it speed up anything else?
A: Yes. If you change one header, it can reduce the number of CPP files that your compiler needs to recompile, or your IDE has to re-scan.
Q: What other reasons are for this PR?
A: It's idiomatic to only include headers if you need them. Also, it will reduce output for those who want to use IWYU for new PRs.
Background:
This is just a remainder PR of what I planned. My original idea was to setup a CI which warns you of useless includes (but not of all issues that IWYU complains about). However, I could not see that this was favored on Discord. A full IWYU CI also has the problem that it (possibly??) needs to compile with
make -j 1, which would make CI really slow.However, for that plan, I had to fix the whole code base to be IWYU compliant - which it now is.