Issue 919 in include-what-you-use: Avoid depending on includes in associated headers

9 views
Skip to first unread message

notifi...@include-what-you-use.org

unread,
May 19, 2021, 6:11:28 PM5/19/21
to include-wh...@googlegroups.com
New issue 919 by mlippautz: Avoid depending on includes in associated headers
https://github.com/include-what-you-use/include-what-you-use/issues/919

Maybe this is already covered and I just could not find the proper docs, sorry.

The current [IWYU rules of Google C++ style guide](https://google.github.io/styleguide/cppguide.html#Include_What_You_Use) seem unsupported.

The interesting part of the rule is: `foo.cc` should include `bar.h` if it uses a symbol from it even if `foo.h` includes `bar.h`.

The current semantics around associated headers seem to be different.

In case it is is not already somehow working, any chance this could be supported via some optional flag?

notifi...@include-what-you-use.org

unread,
May 22, 2021, 8:14:33 AM5/22/21
to include-wh...@googlegroups.com
Comment #1 on issue 919 by kimgr: Avoid depending on includes in associated headers
https://github.com/include-what-you-use/include-what-you-use/issues/919

Interesting, I wonder what the motivation is for that.

The associated-header policy is pretty deeply entrenched in IWYU, and I don't know how hard it would be to conditionalize it.

notifi...@include-what-you-use.org

unread,
May 25, 2021, 10:17:54 AM5/25/21
to include-wh...@googlegroups.com
Comment #2 on issue 919 by mlippautz: Avoid depending on includes in associated headers
https://github.com/include-what-you-use/include-what-you-use/issues/919

It's been in the style guide for quite some time now (last couple years).

Interestingly, the i-w-y-u seems to be based on the Goolge C++ style guide as well which probably didn't contain that part at that time.

notifi...@include-what-you-use.org

unread,
May 25, 2021, 2:10:09 PM5/25/21
to include-wh...@googlegroups.com
Comment #2 on issue 919 by kimgr: Avoid depending on includes in associated headers
https://github.com/include-what-you-use/include-what-you-use/issues/919

Story time...

It did start as an internal Google prototype, that was then open sourced in 2011. By 2013 all known Google maintainers had left, so I've kept the project going since then with the help of many other fantastic volunteers.

The Google style guide has seen quite some revisions since 2011, and IWYU has slowly distanced itself from its very Google-centric origins :-)

There's still a few Googlisms left, such as `#include` sort order and special rules for special filenames e.g. `foo-inl.h`.

notifi...@include-what-you-use.org

unread,
May 26, 2021, 9:12:42 AM5/26/21
to include-wh...@googlegroups.com
Comment #3 on issue 919 by cuzdav: Avoid depending on includes in associated headers
https://github.com/include-what-you-use/include-what-you-use/issues/919

I can't help but be reminded of Bazel's explicit dependency requirements when reading this coding standard from Google. Having a build system and code style with the same (or similar) dependency listing rules makes sense at least, even if it is tedious. But that's just conjecture.

Reply all
Reply to author
Forward
0 new messages