doc: Add "Using IWYU" to Developer Notes
What changed, and why it matters
This commit only updates the project's developer documentation. It adds a new section explaining how to use a code-quality tool called 'include-what-you-use' (IWYU) and links it from an existing style rule. No program code was changed, so it cannot introduce a security vulnerability or fix one.
No security action needed. This is a documentation-only change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies doc/developer-notes.md, adding a ‘Using IWYU’ subsection that describes running the IWYU CI job locally and explains why some IWYU suggestions should be accepted. It also updates the rationale for the existing header-inclusion policy to reference the new section. There are no source-code, build-system, or configuration changes.
Changed components
doc/developer-notes.mdInspect captured patch +16 / −1
diff --git a/doc/developer-notes.md b/doc/developer-notes.md
index d17f8024..b8a16ec0 100644
--- a/doc/developer-notes.md
+++ b/doc/developer-notes.md
@@ -558,6 +558,21 @@ llvm-cov show \
The generated coverage report can be accessed at `build/coverage_report/index.html`.
+### Using IWYU
+
+The [`include-what-you-use`](https://github.com/include-what-you-use/include-what-you-use) tool (IWYU)
+helps to enforce the source code organization [policy](#source-code-organization) in this repository.
+
+To ensure consistency, it is recommended to run the IWYU CI job locally rather than running the tool directly.
+
+In some cases, IWYU might suggest headers that seem unnecessary at first glance, but are actually required.
+For example, a macro may use a symbol that requires its own include. Another example is passing a string literal
+to a function that accepts a `std::string` parameter. An implicit conversion occurs at the callsite using the
+`std::string` constructor, which makes the corresponding header required. We accept these suggestions as is.
+
+Use `IWYU pragma: export` very sparingly, as this enforces transitive inclusion of headers
+and undermines the specific purpose of IWYU.
+
### Performance profiling with perf
Profiling is a good way to get a precise idea of where time is being spent in
@@ -1057,7 +1072,7 @@ Write scripts in Python or Rust rather than bash, when possible.
- *Rationale*: Excluding headers because they are already indirectly included results in compilation
failures when those indirect dependencies change. Furthermore, it obscures what the real code
- dependencies are.
+ dependencies are. The [Using IWYU](#using-iwyu) section describes a tool to help enforce this.
- Don't import anything into the global namespace (`using namespace ...`). Use
fully specified types such as `std::string`.
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.