A tool for use with clang to analyze #includes in C and C++ source files
"Include what you use" means this: for every symbol (type, function variable, or macro) that you use in foo.cc, either foo.cc or foo.h should #include a .h file that exports the declaration of that symbol. The include-what-you-use tool is a program that can be built with the clang libraries in order to analyze #includes of source files to find include-what-you-use violations, and suggest fixes for them.
The main goal of include-what-you-use is to remove superfluous #includes. It does this both by figuring out what #includes are not actually needed for this file (for both .cc and .h files), and replacing #includes with forward-declares when possible.
iwyu 0.23 compatible with llvm+clang 19 is released. Major changes:
@headername
mappingsFor the full list of closed issues see the iwyu 0.23
milestone.
Contributions in this release by Alejandro Colomar, Alfredo Correa, Bolshakov, Chris Down, firewave, Jean-Philippe Gravel, Kim Gräsman, kon72, Michele Caini, Petar Vutov, Richard, scuzqy, ShalokShalom, Thomas Tanner. Sorry if we've missed anyone.
The source code can be downloaded from include-what-you-use-0.23.src.tar.gz. It is equivalent to the 0.23
tag and clang_19
branch.
iwyu 0.22 compatible with llvm+clang 18 is released. Major changes:
<debug/...>
headersFor the full list of closed issues see the iwyu 0.22
milestone.
Contributions in this release by Alejandro Colomar, Bolshakov, David Kilroy, Kim Gräsman, kon72. Sorry if we've missed anyone.
The source code can be downloaded from include-what-you-use-0.22.src.tar.gz. It is equivalent to the 0.22
tag and clang_18
branch.
iwyu 0.21 compatible with llvm+clang 17 is released. Major changes:
typedef
and using
)namespace xyz = foobar
)typedef struct Foo Bar;
)IWYU pragma: always_keep
, which lets a header announce that it should always be kept wherever includedFor the full list of closed issues see the iwyu 0.21
milestone.
Contributions in this release by Alejandro Colomar, Andrey Ali Khan Bolshakov, David Kilroy, Florian Schmaus, Kim Gräsman. Sorry if we've missed anyone.
The source code can be downloaded from include-what-you-use-0.21.src.tar.gz. It is equivalent to the 0.21
tag and clang_17
branch.
iwyu 0.20 compatible with llvm+clang 16 is released. Major changes:
IWYU pragma: export
for forward-declarationstypeid()
For the full list of closed issues see the iwyu 0.20
milestone.
Contributions in this release by Andrey Ali Khan Bolshakov, David Kilroy, Kim Gräsman, Matthew Fennell, Petr Bred, Sameer Rahmani, Seth R. Johnson. Sorry if we've missed anyone.
The source code can be downloaded from include-what-you-use-0.20.src.tar.gz. It is equivalent to the 0.20
tag and clang_16
branch.
iwyu 0.19 compatible with llvm+clang 15 is released. Major changes:
--comment_style
option to control verbosity of 'why' comments--regex
option to select regex dialectbegin_keep
/end_keep
pragmas for protecting ranges of includes or forward-declares-nostdinc++
+ -isystem
)For the full list of closed issues see the iwyu 0.19
milestone.
Contributions in this release by Aaron Puchert, Alejandro Colomar, Andrey Ali Khan Bolshakov, Boleyn Su, Daniel Hannon, Et7f3, fanquake, Jan Kokemüller, Jean-Philippe Gravel, jspam, Kim Gräsman. Sorry if we've missed anyone.
The source code can be downloaded from include-what-you-use-0.19.src.tar.gz. It is equivalent to the 0.19
tag and clang_15
branch.
iwyu 0.18 compatible with llvm+clang 14 is released. Major changes:
Note the breaking change for exit codes; IWYU now always returns zero by default. See the README for more information and manual overrides.
For the full list of closed issues see the iwyu 0.18
milestone.
Contributions in this release by Carlos Galvez and Kim Grasman. Sorry if we've missed anyone.
The source code can be downloaded from include-what-you-use-0.18.src.tar.gz. It is equivalent to the 0.18
tag and clang_14
branch.
iwyu 0.17 compatible with llvm+clang 13 is released. Major changes:
For the full list of closed issues see the iwyu 0.17
milestone.
Contributions in this release by Alejandro Colomar, Bolshakov, David Fetter, Kim Grasman, Omar Sandoval, Salman Javed, Sven Panne. Sorry if we've missed anyone.
The source code can be downloaded from include-what-you-use-0.17.src.tar.gz. It is equivalent to the 0.17
tag and clang_13
branch.
iwyu 0.16 compatible with llvm+clang 12 is released. Major changes:
--load/-l
argument for load limitingFor the full list of closed issues see the iwyu 0.16
milestone.
Contributions in this release by Alexey Storozhev, Florian Schmaus, Kim Grasman, Omer Anson, saki7. Sorry if we've missed anyone.
The source code can be downloaded from include-what-you-use-0.16.src.tar.gz. It is equivalent to the 0.16
tag and clang_12
branch.
iwyu 0.15 compatible with llvm+clang 11 is released. Major changes:
<time.h>
max_align_t
, ptrdiff_t
, and wchar_t
For the full list of closed issues see the iwyu 0.15
milestone.
Contributions in this release by Andrea Bocci, David Callu, Emil Gedda, Florian Schmaus, John Bytheway, Kim Grasman, Liam Keegan, Omar Sandoval, pppyx, Romain Geissler, Seth R Johnson, Tim Gates. Sorry if we've missed anyone.
The source code can be downloaded from include-what-you-use-0.15.src.tar.gz. It is equivalent to the 0.15
tag and clang_11
branch.
iwyu 0.14 compatible with llvm+clang 10 is released. Major changes:
__is_convertible_to
)For the full list of closed issues see the iwyu 0.14
milestone.
Contributions in this release by Aaron Puchert, Kim Grasman, Miklos Vajna, Nick Overdijk, Uladzislau Paulovich. Sorry if we've missed anyone.
The source code can be downloaded from include-what-you-use-0.14.src.tar.gz. It is equivalent to the 0.14
tag and clang_10
branch.
iwyu 0.13 compatible with llvm+clang 9.0 is released. Major changes:
..
--no_fwd_decls
not to remove required forward declarationsfinal
using
declarations in precompiled headerdirectory
from compilation database if availableFor the full list of closed issues see the iwyu 0.13
milestone.
Contributions in this release by Alexander Grund, i-ky, John Bytheway, Julien Cabieces, Kim Grasman, Levente Győző Lénárt, Miklos Vajna, Uladzislau Paulovich and Zachary Henkel. Sorry if we've missed anyone.
The source code can be downloaded from include-what-you-use-0.13.src.tar.gz. It is equivalent to the 0.13
tag and clang_9.0
branch. Note that there's no clang_9.0
tag this time, to avoid tag/branch confusion.
iwyu 0.12 compatible with llvm+clang 8.0 is released. Major changes:
--keep
to mirror IWYU pragma: keep
--cxx17ns
to suggest compact C++17 nested namespaces--no_fwd_decls
to optimize for minimal number of redeclarations-Xiwyu
(so you can use them for Clang args too)For the full list of closed issues see https://github.com/include-what-you-use/include-what-you-use/issues?q=milestone%3A%22iwyu+0.12%22
Contributions in this release by Asier Lacasta, David Robillard, Ignat Loskutov, Jakub Wilk, John Bytheway, J.Ru, Kim Grasman, Martin Villagra, Miklos Vajna, tomKPZ, Tom Rix. Sorry if we've missed anyone.
The source code can be downloaded from include-what-you-use-0.12.src.tar.gz. It is equivalent to the clang_8.0
tag.
iwyu 0.11 compatible with llvm+clang 7.0 is released. Major changes:
--basedir
argument to interpret IWYU output from another source tree--only_re
switch to filter affected files--reorder/--noreorder
switch to toggle reordering of includesFor the full list of closed issues see https://github.com/include-what-you-use/include-what-you-use/issues?q=milestone%3A%22iwyu+0.11%22
Contributions in this release by Asier Lacasta, Christian Venegas, Ignat Loskutov, J.Ru, Kim Grasman, Martin Villagra, Paul Seyfert, Phantal, Philip Pfaffe, Scott Ramsby, Tom Rix, Victor Poughon. Sorry if we've missed anyone.
The source code can be downloaded from include-what-you-use-0.11.src.tar.gz. It is equivalent to the clang_7.0
tag.
iwyu 0.10 compatible with llvm+clang 6.0 is released. Major changes:
--no_fwd_decls
option to avoid replacing includes with forward-declarationsFor the full list of closed issues see https://github.com/include-what-you-use/include-what-you-use/issues?q=milestone%3A%22iwyu+0.10%22
Contributions in this release by bungeman, Kim Gräsman, Alex Kirchhoff, J. Ru, Orgad Shaneh, Christoph Weiss. Sorry if we've missed anyone.
The source code can be downloaded from include-what-you-use-0.10.src.tar.gz. It is equivalent to the clang_6.0
tag.
iwyu 0.9 compatible with llvm+clang 5.0 is released. Major changes:
arguments
field)IWYU pragma: keep
on forward declarationsFor the full list of closed issues see https://github.com/include-what-you-use/include-what-you-use/issues?q=milestone%3A%22iwyu+0.9%22+is%3Aclosed
Contributions in this release by J. Ru, Kim Gräsman, Kristoffer Henriksson, Paul Seyfert. Sorry if we've missed anyone.
NOTE: From now on we will not be able to produce binary releases. There are well-maintained packages for several platforms, and we rely on community contributions to increase availability here.
The source code can be downloaded from include-what-you-use-0.9.src.tar.gz. It is equivalent to the clang_5.0
tag.
iwyu 0.8 compatible with llvm+clang 4.0.0 is released. Major changes:
IWYU pragma: associated
iwyu_tool.py
typedef
types for by-value arguments.IWYU pragma: keep
to work with forward declarations.fix_includes.py
For the full list of closed issues see https://github.com/include-what-you-use/include-what-you-use/issues?q=milestone%3A%22iwyu+0.8%22+is%3Aclosed
Contributions in this release by Eugene Zelenko, ivankoster, Kim Gräsman, Kristoffer Henriksson, mineo, nocnokneo, svenpanne, Volodymyr Sapsai, xuzhen1994. Sorry if we've missed anyone.
The source code can be downloaded from include-what-you-use-0.8.src.tar.gz. It is equivalent to clang_4.0
tag.
iwyu 0.7 compatible with llvm+clang 3.9 is released. Major changes:
#error
if included directly).For the full list of closed issues see https://github.com/include-what-you-use/include-what-you-use/issues?q=milestone%3A%22iwyu+0.7%22+is%3Aclosed
Thanks for all your contributions and help Bothari, Eugene Zelenko, Flamefire, Kim Gräsman. Sorry if I've missed anyone.
The source code can be downloaded from include-what-you-use-0.7.src.tar.gz. It is equivalent to clang_3.9
tag.
iwyu 0.6 compatible with llvm+clang 3.8 is released. In this version we
--no_comments
switch to suppress why-comments.fix_includes.py
generating invalid diff output.For the full list of closed issues see https://github.com/include-what-you-use/include-what-you-use/issues?q=milestone%3A%22iwyu+0.6%22+is%3Aclosed
Thanks for all your contributions and help JVApen, Kim Gräsman, Philip Pfaffe, pseyfert, realazthat, Sylvestre Ledru, ThosRTanner. Sorry if I've missed anyone.
The source code can be downloaded from include-what-you-use-0.6.src.tar.gz. It is equivalent to clang_3.8
tag.
iwyu 0.5 compatible with llvm+clang 3.7 is released. In this version we
size_t
from multiple headers.For the full list of closed issues see https://github.com/include-what-you-use/include-what-you-use/issues?q=milestone%3A%22iwyu+0.5%22+is%3Aclosed
Thanks for all your contributions Scott Howard, bungeman, tpltnt, Chris Glover, Kim Gräsman. And thank you for all you help Jérémie Delaitre, Richard Thomson, dpunset, Earnestly, Dave Johansen, ThosRTanner. Sorry if I've missed anyone.
The source code can be downloaded from include-what-you-use-0.5.src.tar.gz. It is equivalent to clang_3.7
tag.
iwyu 0.4 compatible with llvm+clang 3.6 is released. It contains the following changes:
For the full list of closed issues see https://code.google.com/p/include-what-you-use/issues/list?can=1&q=closed-after%3A2014%2F10%2F23+closed-before%3A2015%2F6%2F2
This release received many contributions and I want to thank SmSpillaz, Paul Redmond, Chris Glover, Ryan Pavlik, showard314, Fabian Gruber, Kim Gräsman for your help. And thanks to Dave Johansen, MMendez534, Sylvestre Ledru for packaging include-what-you-use. Sorry if I've missed anyone.
The source code can be downloaded from include-what-you-use-0.4.src.tar.gz. It is equivalent to clang_3.6
tag.
iwyu 0.3 compatible with llvm+clang 3.5 is released. In this version we have
For the full list of closed issues see https://code.google.com/p/include-what-you-use/issues/list?q=closed-after%3A2014%2F02%2F23&can=1
The source code can be downloaded from include-what-you-use-3.5.src.tar.gz. It is equivalent to clang_3.5
tag.
iwyu version compatible with llvm+clang 3.4 is released. The source code can be downloaded from include-what-you-use-3.4.src.tar.gz. It is equivalent to clang_3.4
tag.
We are moving downloads to Google Drive. iwyu version compatible with llvm+clang 3.3 can be found at include-what-you-use-3.3.tar.gz. It is equivalent to clang_3.3
tag.
Now that clang 3.0 is out, I released a version of iwyu that works against clang 3.0. It is equivalent to r330. It is available in the 'downloads' section on the side pane. To use, just cd
to llvm/tools/clang/tools
in your llvm/clang tree, and untar include-what-you-use-3.0-1.tar.gz
from that location. Then cd to include-what-you-use
and type make
. (A cmakefile is also available.) You can run make check-iwyu
to run the iwyu test suite.
It was just pointed out to me the tarball I built against llvm+clang 2.9 doesn't actually compile with llvm+clang 2.9. I must have made a mistake packaging it. I've tried again; according to my tests, anyway, the new version works as it's supposed to.
I finally got around to releasing a tarball that builds against llvm+clang 2.9. See the 'downloads' section on the side pane. This is a rather old version of iwyu at this point, so you'll do much better to download a current clang+llvm and the svn-root version of include-what-you-use, and build from that. See README.txt for more details.
Work has been continuing at a furious pace on include-what-you-use. It's definitely beta quality by now. :-) Well, early beta. I've not been making regular releases, but the SVN repository is being frequently updated, so don't take the lack of news here to mean a lack of activity.
I'm very pleased to announce the very-alpha, version 0.1 release of include-what-you-use. See the wiki links on the right for instructions on how to download, install, and run include-what-you-use.
I'm releasing the code as it is now under a "release early and often" approach. It's still very early in iwyu, and the program will probably have mistakes on any non-trivial piece of code. Furthermore, it still has google-specific bits that may not make much sense in an opensource release. This will all get fixed over time. Feel free to dig in and suggest patches to help the fixing along!
If you want to follow the discussion on include-what-you-use, and/or keep up to date with changes, subscribe to the Google Group.