-
Notifications
You must be signed in to change notification settings - Fork 627
Open
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
Include What You Use (no more, no less)
References:
- https://google.github.io/styleguide/cppguide.html#Include_What_You_Use
- https://rawgit.com/AliceO2Group/CodingGuidelines/master/coding_guidelines.html#Header_Files
- https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#sf10-avoid-dependencies-on-implicitly-included-names
- https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rs-contained
- https://llvm.org/docs/CodingStandards.html#include-as-little-as-possible
- https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md
Tools:
- https://clang.llvm.org/extra/clang-tidy/checks/misc/include-cleaner.html
- https://clang.llvm.org/extra/clang-tidy/checks/llvm/include-order.html
- https://clangd.llvm.org/design/include-cleaner
- https://clangd.llvm.org/guides/include-cleaner
- https://github.com/bkryza/clang-include-graph
Ideas:
- A file which does not include what it uses does not compile. This can be tested with:
(It should be enough to check for non-zero exit code to detect compilation errors.)
clang-tidy <file>
However, if it compiles, it does not mean that all used headers are included directly nor that no unused headers are included. - When the file compiles, the includes in it can be fixed automatically with:
until there are no warnings left.
clang-tidy --fix -checks=-*,misc-include-cleaner <file>
- Once all headers are self-contained, source files can be fixed with the same procedure.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed