A small utility that helps you include the right C++ headers.
https://github.com/orlp/iwyu.git
IWYU is a small utility that helps you include the right C++ headers. It helps you detect superfluous headers as well as potentially missing headers.
IWYU requires PLY. Run pip install --user ply to install it.
The tool is not particularly smart. The first issue is that IWYU doesn't compile, parse or even preprocess the code. It merely relies on lexical analysis to extract identifiers and their potential namespaces.
Secondly, it relies on manual input to learn where each symbol comes from. If the tool encounters a symbol in a namespace you're interested in that it hasn't seen before, it will ask you to input the correct header.
Despite these limitations the tool is fast and useful. The database is in plain text and is intended to be edited. It contains all the symbols and their header files, and has some tricks up it's sleeve:
? std::*
! std::experimental::*
std::ios_base::* =
To run IWYU simply execute python iwyu.py <FILE>... and it will display a
minimal set of headers for each file. IWYU will not edit your source files.