Include what you use
This is outdated. The setup with clang 3.5 is no longer compatible with our C++20 setup. If we want to continue using IWYU, we'd have to update the setup.
You can use the include-what-you-use (IWYU) tool to check which includes and forward definitions are missing/redundant. However, the tool outputs many false positives, so each suggested change should be double-checked.
Instructions
1 # Make sure that clang-3.5 and the corresponding header files are installed.
2 sudo apt-get install clang-3.5 libclang-3.5-dev
3
4 # Install IWYU.
5 git clone https://github.com/include-what-you-use/include-what-you-use.git --branch clang_3.5
6 mkdir build
7 cd build
8 cmake -DLLVM_PATH=/usr/lib/llvm-3.5 ../
9 make
10 sudo mv include-what-you-use /usr/bin/
11
12 # Change into src/search.
13
14 # Check file:
15 include-what-you-use -g -std=c++11 -Wall -Wextra -pedantic -Werror -Iext -O3 -DNDEBUG -fomit-frame-pointer -c globals.cc -o .obj/globals.release.o
Optionally use mapping file to suppress some warnings
1 # File iwyu.imp:
2 [
3 { include: ['"option_parser_util.h"', 'private', '"option_parser.h"', 'public'] },
4 { include: ['<ext/alloc_traits.h>', 'private', '<vector>', 'public'] },
5 { symbol: ["size_t", "private", "<vector>", "public"] },
6 { symbol: ["assert", "private", "<cassert>", "public"] },
7 ]
8
9 include-what-you-use -Xiwyu --mapping_file=iwyu.imp -g -std=c++11 -Wall -Wextra -pedantic -Werror -Iext -O3 -DNDEBUG -fomit-frame-pointer -c globals.cc -o .obj/globals.release.o