We can use this issue for feedback and discussion on actions to be taken. There are probably some false positives and some recommendations we do not want to follow. But most of it is certainly useful. We can proceed module by module for example.
The tool fix_includes.py can take this output and fix the code automatically. I will look into if we can use it to produce some nice diffs.
version used:
[poughov@node151 build]$ include-what-you-use --versioninclude-what-you-use 0.9 (git:15b3f1d) based on clang version 5.0.0 (https://github.com/llvm-mirror/clang.git 7e8743f82ac7957c66d9c2444996be5b1218673b) (https://github.com/llvm-mirror/llvm.git 657c31173ea30090583e40c7a9204561d9c2d8c4)
I patched include-what-you-use to add a new option to allow us to do it module by module. Then I went through the diff for everything in Modules/Core and edited it manually to keep only what make most sense. It's in this branch.
By doing this I learned that:
It takes a lot of effort to make something useful from the raw output of include-what-you-use (like you said @lhermitte)
It does not even analyse files that don't have a corresponding .cxx. So all of our header-only classes are simply ignored (and we have a LOT of those)
Most of what it suggests are additions, not deletions (although there are a few). Since my main interest is in removing includes in order to reduce build time, I will probably not go through the same effort for all OTB modules.
It does not even analyse files that don't have a corresponding .cxx. So all of our header-only classes are simply ignored (and we have a LOT of those)
Yes. That a recurring problem with json databases generated by CMake. They start from translation units, and have no visibility over unused header files. We need to have a lot of tests that cover all files, functions, etc.
It does not even analyse files that don't have a corresponding .cxx. So all of our header-only classes are simply ignored (and we have a LOT of those)
Yes. That a recurring problem with json databases generated by CMake. They start from translation units, and have no visibility over unused header files. We need to have a lot of tests that cover all files, functions, etc.
Since my main interest is in removing includes in order to reduce build time,
Refactoring may give better results here. I've seen a few tools on this topic -- graphs generated by doxygen+dot are a poor man's solution . BTW, it reminds me of a refactoring proposal I made for ITK that wasn't accepted (there are some files that collect miscellaneous traits and that include too many things)