Details
-
Improvement
-
Resolution: Fixed
-
Major - P3
-
None
-
None
-
Fully Compatible
-
Service Arch 2022-03-21, Service Arch 2022-04-04
-
1
Description
Propose removing MONGO_ALLOW_INCLUDE_INVARIANT_H (nee MONGO_INCLUDE_INVARIANT_H_WHITELISTED).
Maybe rename invariant.h to assert_util_detail.h or similar to indicate the relationship better.
The #ifdef/#error/#endif handshake in invariant.h interferes with indexing that header, as it can't be included by a trivial .cpp file to yield a successful compilation. This is mildly annoying.
The benefit it is meant to provide is hazy or maybe obsolete. It's meant to force invariant callers to include assert_util.h. But the allowlist requirement is not transitive and cannot be. Most high-level files using invariant.h without assert_util.h do so by including one of the files on the allow list (usually base/string_data.h). So they skirt the requirement, perhaps inadvertently.
I can't see what the allowlist is trying to protect. I think it's trying to produce a culture where assert_util.h will always be preferred to direct inclusion of invariant.h, which is a good thing. I think maybe renaming invariant.h to assert_util_core.h or assert_util_detail.h and retaining the admonition at the top:
/**
|
* This header is separated from assert_util.h so that the low-level
|
* dependencies of assert_util.h (e.g. mongo/base/status_with.h,
|
* mongo/base/status.h, mongo/base/string_data.h) can use the invariant macro
|
* without causing a circular include chain. It should never be included
|
* directly in any other files.
|
*/ |
would do this in a more direct way that would not have any technical side effects.
Attachments
Issue Links
- related to
-
SERVER-51061 Rename c preprocessor macro that guards access to invariant.h header.
-
- Closed
-