xref: /aosp_15_r20/external/pytorch/tools/iwyu/run.sh (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1# Run include-what-you-use on a file or folder
2# e.g. tools/iwyu/run.sh aten/src/ATen/native/sparse/SparseBlas.cpp
3# Which will print suggested changes to the console
4#
5# Currently the include mappings aren't good enough to trust iwyu's
6# output e.g. we probably just want to include Tensor.h and trust it
7# brings in the c10 headers. So, for now, use iwyu as a guide and
8# update includes manually.
9
10TORCH_ROOT=$(dirname $(dirname $(dirname $(readlink -f $0))))
11
12iwyu_tool -p $TORCH_ROOT/build $@ -- -Wno-unknown-warning-option -Xiwyu \
13          --no_fwd_decls -Xiwyu --mapping_file=$TORCH_ROOT/tools/iwyu/all.imp \
14    | python $TORCH_ROOT/tools/iwyu/fixup.py
15