Skip to content

Add include-what-you-use (IWYU) support for header dependency checking#7405

Draft
Claude wants to merge 3 commits intomasterfrom
claude/add-iwyu-target-to-clean-headers
Draft

Add include-what-you-use (IWYU) support for header dependency checking#7405
Claude wants to merge 3 commits intomasterfrom
claude/add-iwyu-target-to-clean-headers

Conversation

@Claude
Copy link
Contributor

@Claude Claude AI commented Mar 6, 2026

Adds tooling to detect and prevent unnecessary header inclusions that cause excessive recompilation. For example, modifying include/guidance/intersection_handler.hpp currently triggers recompilation of unrelated files like src/updater/updater.cpp and src/contractor/contractor.cpp.

Changes

  • CI Workflow (.github/workflows/iwyu.yml): New job using LLVM 18 and IWYU from apt.llvm.org, runs on PRs and master. Reports header issues as warnings without blocking builds.

  • CMake Integration: Added ENABLE_IWYU option (OFF by default) to run IWYU during compilation. Follows same pattern as ENABLE_CLANG_TIDY.

  • Mapping File (iwyu.imp): Configured standard library and third-party dependency mappings to reduce false positives.

Usage

cmake .. -DENABLE_IWYU=ON -DCMAKE_CXX_COMPILER=clang++-18
make -j$(nproc)

IWYU suggestions appear during compilation. Use iwyu_tool.py and fix_includes.py for automated fixes.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add include-what-you-use target to clean headers dependencies</issue_title>
<issue_description>https://include-what-you-use.org/ tool can help to cleanup headers dependencies.

For example modification of include/extractor/guidance/intersection_handler.hpp triggers compilation of src/updater/updater.cpp and src/contractor/contractor.cpp that should not happen.

Adding a linting job to avoid superfluous and cyclic inclusions would be a plus.
</issue_description>

<agent_instructions>Create an additional CI job. It should run on ubuntu-latest and use the Debian/Ubuntu packaging available from https://apt.llvm.org, you'll need the following packages installed:

llvm--dev
libclang--dev
clang-
Packaging for other platforms will likely be subtly different.

The CI job should only pass if iwyu is without any include errors. </agent_instructions>

Comments on the Issue (you are @claude[agent] in this section)

Claude AI and others added 2 commits March 6, 2026 20:16
Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
@Claude Claude AI changed the title [WIP] Add include-what-you-use target to clean headers dependencies Add include-what-you-use (IWYU) support for header dependency checking Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add include-what-you-use target to clean headers dependencies

2 participants