Skip to content

various: use iwyu (include-what-you-use) to analyze includes

Garrit Franke git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest4 patches 4 repliesIn review

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4contrib: add iwyu scriptcontrib/iwyu/README contrib/iwyu/iwyu.sh+35 -01 reply
2/4bisect.c: remove unnecessary includebisect.c+0 -12 replies
3/4serve.c: remove unnecessary includeserve.c+0 -10 replies
4/4apply.c: remove unnecessary includebuiltin/apply.c+0 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/4] various: use iwyu (include-what-you-use) to analyze includes

I'm sorry about the half-baked patch of mine. I initially noticed that the "hash-lookup.h" wasn't needed (which was a correct assumption), and then went overboard when trying to clean up the other includes.

This is truly a rookie mistake that only wastes the time of everyone involved. This won't happen again!

Quoted 6 lines · Ævar Arnfjörð Bjarmason

... For anyone interested in pursuing this, I think using the excellent include-what-you-use tool would be a nice start.

We could even eventually add it to our CI if the false positive rate isn't bad (I haven't checked much):
https://github.com/include-what-you-use/include-what-you-use

This seems to be a really nice tool indeed. I wouldn't be comfortable adding it to the CI just yet, but it did make it considerably easier to spot includes that could safely be removed.

I think we could try battle-testing this tool in the codebase to get a sense of how it behaves. To start, I added your reference-command to a script under "contrib/iwyu" and ran it against the files you noted. Before breaking a bulk of the files, I wanted to make sure that this undertaking is headed in the right direction.

Feedback is of course welcomed!

Garrit Franke (4):
contrib: add iwyu script
bisect.c: remove unnecessary include
serve.c: remove unnecessary include
apply.c: remove unnecessary include

 bisect.c             |  1 -
 builtin/apply.c      |  1 -
 contrib/iwyu/README  | 33 +++++++++++++++++++++++++++++++++
 contrib/iwyu/iwyu.sh |  2 ++
 serve.c              |  1 -
 5 files changed, 35 insertions(+), 3 deletions(-)
 create mode 100644 contrib/iwyu/README
 create mode 100755 contrib/iwyu/iwyu.sh
Signature · 1 line
2.35.1