[cfe-dev] [RFC] Add include-what-you-use tool to clang-tools-extra

Kim Gräsman via cfe-dev cfe-dev at lists.llvm.org
Mon Sep 4 10:41:15 PDT 2017


Hi all,

This is a proposal to integrate include-what-you-use [1] into clang-tools-extra.

# Background
The include-what-you-use tool analyzes #includes in C and C++ files and
recommends how to improve them. The goal is to capture symbol dependencies in
code and produce the minimal set of #includes to satisfy these symbol
dependencies. For more information you can check the project site [2], docs, and
presentation from 2010 LLVM Developers' Meeting [3].

# Benefits
Migration to clang-tools-extra doesn't come without a cost, so I want to list
some of the benefits this move yields.

## For Clang community
* Ability to reuse some of IWYU analysis for other purposes. Currently IWYU is
  distributed as a CLI tool and has no API but it is possible to split out a
  separate library. I think there could be some integration potential with the
  budding refactoring tools, for example.
* More community input in deciding further IWYU direction to help it to be more
  useful for various parties.

## For include-what-you-use users
* Easier distribution and use. For users already using other Clang tools it
  should be easier to use IWYU as any other Clang tool. I also expect it to make
  life easier for people packaging include-what-you-use for various *nix
  distributions.
* Moving the tool towards consistency with other Clang tools.

## For include-what-you-use project
* Exposure to more users.
* Easier release process. Instead of releasing IWYU separately, it could be
  bundled with LLVM+Clang releases. It shouldn't incur more work for LLVM+Clang
  releases as the main complexity comes from tracking different branches and
  building binaries for different platforms.
* More resiliency as the project becomes more community-owned instead of
  personally-owned.

# Potential downsides
When new Clang sub-projects are proposed, one of the most common concerns is the
maintenance burden. Dumping the code and walking away to let the community
support the code is unacceptable. The longevity of the project demonstrates
commitment to maintaining the project. The history on GitHub shows that
include-what-you-use is not a passing fancy that will be discarded and forgotten
in a week or two.

What is your opinion, is there value in having include-what-you-use in
clang-tools-extra?

Thanks for any input,
- Kim

[1] https://github.com/include-what-you-use/include-what-you-use
[2] https://include-what-you-use.org/
[3] http://llvm.org/devmtg/2010-11/



More information about the cfe-dev mailing list