Apply clangd IWYU export pragmas to transitive includes #1492
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To improve the quality of clangd's IWYU diagnostics, this PR applies the IWYU "export" macro to deliberate transitive includes.
Include directives which are "exported" are:
\par Includes), orAll clangd IWYU warnings in v1 components (or required by v1 components) are addressed. Reordering or removal of includes in v_noabi public headers are skipped to avoid unnecessary potential for breaking changes.
Even with these changes, the IWYU tool still emits noise, e.g.
<bsoncxx/private/bson.hh>exports<bson/bson.h>, but some components still emit the following warnings:despite other entities provided by
<bson/bson.h>being (correctly) handled by the export. The<bson/bson.h>might need to be annotated with similar comments for these warnings to go away. Similarly,<type_traits>does not seem to be identified via<bsoncxx/private/type_traits.hh>-><bsoncxx/v1/detail/type_traits.hpp>-><type_traits>either. (Possibly related: include-what-you-use/include-what-you-use#1645)Update: confirmed these are due to the lack of IWYU export pragmas in
<bson/bson.h>: mongodb/mongo-c-driver#2167.Fixing warnings for missing IWYU of third party library headers (e.g. Catch2 and
<catch2/catch_message.hpp>) are skipped by this PR.Unsure if there is a nice way to silence these warnings for headers we do not own.The following can be added to the clangd configuration file (either per-project or global):