Skip to content

Set up IWYU #70

Open
Open

Description

@EpsilonPrime

It would be convenient to be able to run IWYU similarly to how we can run clang format and clang tidy today.

Activity

  1. ingomueller-net commented on Apr 10, 2026

    @ingomueller-net
    Contributor

    I looked quite a bit into this:

    • XXX: Play with CI to set up IWYU #151 attempts to set up IWYU. Making it run in CI and invoking it from CMake works. A few caveats, though:
      • [biggest] Running IWYU isn't idempotent: Every time I reran it, it changed things again, often adding and removing the same include in subsequent runs. This makes it unsuitable as a CI check.
      • [big] IWYU sometimes doesn't understand which is the public header that users should include. This is solved with "mapping files." The problem is that they may depend on the system: the mappings that worked on my machine were not enough to make things work in CI. If every user needs to first set up their own mappings, chances are high that this will create a lot of churn and frustration.
      • [solvable] The integration with CMake does not provide or apply fixes and running iwyu_tool.py requires several non-trivial parameters to work as intended. We could probably set up a CMake target for that but I haven't done that yet.
    • style(iwyu): set up include cleaner of clang-tidy #153 just uses clang-tidys misc-include-cleaner. This works with the infra that we already have and is a lot more reliable and stable. Only caveat:
      • It does not modify header files.

    I think I'll leave it at that for now. What we could do is to add IWYU to CMake but not enforce it and decide manually which suggestions to apply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions