[SERVER-81059] everything now includes <boost/preprocessor/control/iif.hpp> Created: 13/Sep/23  Updated: 29/Oct/23  Resolved: 24/Sep/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.2.0-rc0

Type: Improvement Priority: Minor - P4
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
Related
related to SERVER-81394 replace `invariant` etc uses of boost... Closed
Assigned Teams:
Server Development Platform
Backwards Compatibility: Fully Compatible
Sprint: Service Arch 2023-10-02
Participants:

 Description   

An include for a rather obscure boost preprocessor header has been added by the IWYU sweep, to over 1500 c++ source files.

#include <boost/preprocessor/control/iif.hpp>

I don't really understand why IWYU would do this to a file like
"src/mongo/db/commands/server_status_metric.h", which doesn't have any macros inside it at all. It seems like IWYU made a mistake here and it should be undone.

I think maybe one of the other headers needs something from the iif.hpp header and IWYU didn't resolve that dependency appropriately.



 Comments   
Comment by Githook User [ 23/Sep/23 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-81059 bulk-revert of include of boost iif.hpp
Branch: master
https://github.com/mongodb/mongo/commit/eced867739c05384f20dbebdcde50916d9ab8420

Comment by Zack Winter [ 14/Sep/23 ]

It looks like it's getting triggered by "invariant()" since it uses "BOOST_PP_OVERLOAD", which eventually expands to use BOOST_PP_IIF_0: https://github.com/10gen/mongo/blob/master/src/mongo/util/assert_util_core.h#L106

```
[ Exiting to ] src/mongo/db/commands/server_status_metric.h:44:1
[ Use macro ] src/mongo/db/commands/server_status_metric.h:172:5: invariant (from src/mongo/util/assert_util_core.h:105:9)
[ Use macro ] src/mongo/db/commands/server_status_metric.h:172:5 <Spelling=<scratch space>:197:1>: BOOST_PP_IIF_0 (from src/third_party/boost/boost/preprocessor/control/iif.hpp:31:10)
[ Use macro ] src/mongo/db/commands/server_status_metric.h:172:5 <Spelling=<scratch space>:198:1>: MONGO_invariant_1 (from src/mongo/util/assert_util_core.h:65:9)
[ Use macro ] src/mongo/db/commands/server_status_metric.h:173:5: invariant (from src/mongo/util/assert_util_core.h:105:9)
[ Use macro ] src/mongo/db/commands/server_status_metric.h:173:5 <Spelling=<scratch space>:202:1>: BOOST_PP_IIF_0 (from src/third_party/boost/boost/preprocessor/control/iif.hpp:31:10)
[ Use macro ] src/mongo/db/commands/server_status_metric.h:173:5 <Spelling=<scratch space>:203:1>: MONGO_invariant_1 (from src/mongo/util/assert_util_core.h:65:9)
[ Exiting to ] src/mongo/db/commands/server_status_metric.cpp:31:1
```

Probably a bug in IWYU where it believes that assert_util_core.h is exporting BOOST_PP_IIF_0 and server_status_metric.h (among others) are calling it directly.

I created https://github.com/10gen/mongo/pull/15633 to skip over it, but it's still pretty annoying since the way we're using iwyu seems to require us to create a comment in every file that ignores it.

Comment by Billy Donahue [ 13/Sep/23 ]

The file defines macros beginning with BOOST_PP_IIF.
We only use these in platform/visibility.h and we include the header there.

But boost uses BOOST_PP_IIF extensively internally.
Presumably all boost headers are also correctly including this thing when they use it, so it's really unclear why the IWYU pass would have added this everywhere.

I think we should just do a trivial "grep and destroy" to back this out.

Generated at Thu Feb 08 06:45:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.