iwyu: Document or remove some pragma: export and other improvements#34639
iwyu: Document or remove some pragma: export and other improvements#34639hebasto wants to merge 6 commits intobitcoin:masterfrom
pragma: export and other improvements#34639Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
maflcko
left a comment
There was a problem hiding this comment.
Personally I think it is fine to use export for headers that are always (possibly with a single exception) simply forwarded via another header.
I think this applies to all cases here, except for the chrono one?
e61ec11 to
de4c286
Compare
|
Thank you for the review! Your feedback has been addressed. |
pragma: export and other improvementspragma: export and other improvements
src/util/log.h
Outdated
| #ifndef BITCOIN_UTIL_LOG_H | ||
| #define BITCOIN_UTIL_LOG_H | ||
|
|
||
| // Export, as `logging/categories.h` is practically not used stand-alone. |
There was a problem hiding this comment.
is practically not used stand-alone.
Not sure I understand this comment. Why are we doing this, instead of including the things that we are using? Why does it matter if they might only be used when some other header is also used?
There was a problem hiding this comment.
Also, has the rationale for when to do this (or not), been documented in the developer notes?
There was a problem hiding this comment.
is practically not used stand-alone.
Not sure I understand this comment. Why are we doing this, instead of including the things that we are using? Why does it matter if they might only be used when some other header is also used?
I've reverted this change to its initial variant.
Also, has the rationale for when to do this (or not), been documented in the developer notes?
It seems reasonable to update the developer notes once we work through the entire codebase.
There was a problem hiding this comment.
It seems reasonable to update the developer notes once we work through the entire codebase.
Why? The developer docs should reflect how we want new code to be written, and current code to be updated, otherwise you're just guaranteeing having to rework code again later on, rather than having it introduced/updated to how it should be, now.
There was a problem hiding this comment.
If this is a blocker, maybe the dev notes can be updated to say that a comment with the rationale are required for exports?
There was a problem hiding this comment.
It seems reasonable to update the developer notes once we work through the entire codebase.
Why? The developer docs should reflect how we want new code to be written, and current code to be updated, otherwise you're just guaranteeing having to rework code again later on, rather than having it introduced/updated to how it should be, now.
If this is a blocker, maybe the dev notes can be updated to say that a comment with the rationale are required for exports?
Thanks! Done.
de4c286 to
8a149c6
Compare
|
Thank you for the review! Your feedback has been addressed. |
8a149c6 to
7713575
Compare
|
review ACK 7713575 🦆 Show signatureSignature: |
7713575 to
9791771
Compare
|
I don't understand what makes that handful of .cpp files special? Why do only a few require a direct |
They are not special rather ones where IWYU warnings are treated as errors: bitcoin/ci/test/03_test_script.sh Line 186 in e09b816 It is assumed that this will be enforced for the entire codebase in the future. |
|
Only change is in the last commit. review ACK 9791771 💧 Show signatureSignature: |
Sorry, but this progression just doesn't make sense to me. As @maflcko said, the categories are needed any time a log macro is used. Using both includes everywhere (eventually) would be redundant and confusing. It seems the original intent of But fundamentally,
So it makes sense to me to either:
I don't see any harm in keeping the enum in a separate header for cleanliness, so I'd prefer the latter. |
ryanofsky
left a comment
There was a problem hiding this comment.
Code review ACK 9791771.
I agree with @theuni it could be a good idea to just document the export in the last commit 9791771 instead of removing it because right now the util/log.h header explicitly references BCLog::LogFlags::ALL, so it has a hard dependency on the categories.h include.
(We could break the util/log.h dependency on categories.h by defining Category as std::optional<uint64_t> instead of uint64_t and using nullopt to represent an unset category instead of BCLog::LogFlags::ALL. Or we could go the other direction and move the categories into util and drop the idea of having an opaque category field. @stickies-v introduced the opaque category field in 5b01eae from #34374 so I'm not actually sure about reasons it is opaque. But if seems like either the field should be opaque OR util/log.h should depend on the non-opaque enum, but not both.)
Including the missing `<span>` header in `serialize.h` allows IWYU to correctly evaluate its redundancy elsewhere.
This makes `threadsafety.h` agnostic to the actual implementation.
9791771 to
6a27dcd
Compare
|
Since most reviewers agreed to export Let me know if you have a specific alternative in mind for the inline comment. |
There was a problem hiding this comment.
Code review ACK 6a27dcd, just keeping the log.h categories export and documenting it which makes sense for now.
As mentioned previously in longer term I think it'd make sense to either (1) drop the log.h dependency on categories.h if category is supposed to be opaque within util (easy to do with std::optiona) or (2) move categories into util and drop the idea that categories should be opaque. The current middle ground doesn't seem to make a lot of sense. The util library should either know about category values or not know about them. It shouldn't pretend to not know about them and also directly reference one of the values it doesn't know about.
|
Only change is the last commit, again review ACK 6a27dcd 😌 Show signatureSignature: |
|
|
||
| // This header declares threading primitives compatible with Clang | ||
| // Thread Safety Analysis and provides appropriate annotation macros. | ||
| #include <threadsafety.h> // IWYU pragma: export |
There was a problem hiding this comment.
nit: I wonder if src/sync_unlogged.h should not be moved into src/util/sync_unlogged.h, because it seems like a low-level utility. Same for threadsafety.h. No need to re-touch here, but the move should be trivial, because the files are now basically only used in two places.
|
A commit updating Developer Notes has been added. |
This PR is a prerequisite for #34448. It was split into a separate PR to limit the scope and minimize potential merge conflicts.
The first commit improves the accuracy of IWYU suggestions within our heavily templated code. Note that, for now, the
serialize.hheader itself is excluded from IWYU inspection because it lacks a corresponding source file.The remaining commits follow the Developer Notes guidance: