doc: Add "Using IWYU" to Developer Notes
This commit is contained in:
1 file changed
+16
-1
+16
-1
@@ -558,6 +558,21 @@ llvm-cov show \
|
|||||||
|
|
||||||
The generated coverage report can be accessed at `build/coverage_report/index.html`.
|
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
|
### Performance profiling with perf
|
||||||
|
|
||||||
Profiling is a good way to get a precise idea of where time is being spent in
|
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
|
- *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
|
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
|
- Don't import anything into the global namespace (`using namespace ...`). Use
|
||||||
fully specified types such as `std::string`.
|
fully specified types such as `std::string`.
|
||||||
|
|||||||
Reference in new issue
Block a user