Skip to content

Annotate facade header with IWYU export annotation#3027

Closed
hzeller wants to merge 1 commit into
boostorg:developfrom
hzeller:feature-20250830-iwyu-pragma
Closed

Annotate facade header with IWYU export annotation#3027
hzeller wants to merge 1 commit into
boostorg:developfrom
hzeller:feature-20250830-iwyu-pragma

Conversation

@hzeller

@hzeller hzeller commented Aug 30, 2025

Copy link
Copy Markdown

Without that annotation, tools such as clang-tidy or the clangd language server (as well as many other tools) will complain about headers not directly providing a symbol if users include beast.hpp; With this annotation, they know.

Documentation IWYU
https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md#iwyu-pragma-begin_exportsend_exports

Documentation llvm include cleaner/clang-tidy/clangd https://clangd.llvm.org/design/include-cleaner#iwyu-pragmas

Without that annotation, tools such as `clang-tidy` or
the `clangd` language server (as well as many other tools)
will complain about headers not directly providing a symbol
if users include `beast.hpp`; With this annotation, they
know.

Documentation IWYU
https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md#iwyu-pragma-begin_exportsend_exports

Documentation llvm include cleaner/clang-tidy/clangd
https://clangd.llvm.org/design/include-cleaner#iwyu-pragmas

Signed-off-by: Henner Zeller <h.zeller@acm.org>
@codecov

codecov Bot commented Aug 30, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.11%. Comparing base (9b24b28) to head (17604c3).
⚠️ Report is 24 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3027      +/-   ##
===========================================
+ Coverage    93.09%   93.11%   +0.02%     
===========================================
  Files          176      176              
  Lines        13647    13647              
===========================================
+ Hits         12704    12708       +4     
+ Misses         943      939       -4     

see 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9b24b28...17604c3. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sehe

sehe commented Aug 30, 2025

Copy link
Copy Markdown
Contributor

Does IWYU not honour -isystem includes (e.g. via CMake SYSTEM includes)?

@hzeller

hzeller commented Aug 30, 2025

Copy link
Copy Markdown
Author

-isystem does not make a difference here.

Often, warnings for -isystem-provided headers would be suppressed.

But here we have a different situation, and want to guide warnings in the project itself: IWYU marks includes relevant or not given if they provide a symbol directly in a particular header (and by default it does not follow further includes). That makes sure that symbols don't come from transitive dependencies (accidental visibility of symbols due to the textual concatenation of C headers, the very thing that IWYU wants to help prevent).

So if we have a header that is indeed meant to provide a symbol one nest-level deeper, we can annotate it like what I've done here.

@vinniefalco

Copy link
Copy Markdown
Member

This looks benign

@sehe

sehe commented Sep 1, 2025

Copy link
Copy Markdown
Contributor

But here we have a different situation

Thank you. It's more clear to me now that this is not "silencing warnings" but annotating the facade header(s) specifically.

@ashtum

ashtum commented Sep 4, 2025

Copy link
Copy Markdown
Collaborator

@hzeller, I'm using clangd-20 and clang-tidy-20 with the -misc-include-cleaner check, but I wasn't able to reproduce the warning you mentioned. Could you please provide more details on how to reproduce the issue?

@ashtum

ashtum commented Feb 9, 2026

Copy link
Copy Markdown
Collaborator

I’m closing this for now as I wasn’t able to reproduce the reported issue. I’d appreciate it if the OP could provide a bit more information so we can investigate further.

@ashtum ashtum closed this Feb 9, 2026
hzeller added a commit to hzeller/OpenROAD that referenced this pull request Feb 11, 2026
They are often meant to be included as a single
header that then internally includes all the
internal headers.

However, the single headers don't provide the necessary
IWYU annotations for `misc-include-cleaner` to give
proper guidance. So for now, misc-include-cleaner warnings
w.r.t. boost are more noise then useful.

I have a few boost upstream PRs open, but it either
goes slow to review, or they require met to show that
it is helping, which I didn't have time to yet.
Even once all these are merged, we need to wait for them
to show up in a released version.

(e.g.
  boostorg/geometry#1427
  boostorg/beast#3027
)

Signed-off-by: Henner Zeller <h.zeller@acm.org>
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.

4 participants