[SERVER-68121] clang-tool boost::optional -> std::optional migration Created: 18/Jul/22  Updated: 19/Jan/24

Status: Backlog
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Billy Donahue Assignee: Backlog - Service Architecture
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Issue split
split to SERVER-68378 Remove all uses of boost/optional_io.hpp Closed
Related
related to SERVER-68246 change calls to `boost::optional` mem... Closed
is related to SERVER-26542 Migrate to std::optional Backlog
is related to SERVER-69953 Timer and Stopwatch should be copy as... Closed
Assigned Teams:
Service Arch
Participants:

 Description   

Ticket created to track a skunkworks project in a persistent place.



 Comments   
Comment by Billy Donahue [ 09/Mar/23 ]

Draft PR to integrate this check into the mongo repo's clang-tidy plugins framework.
https://github.com/10gen/mongo/pull/11136

Comment by Billy Donahue [ 22/Jul/22 ]

That is interesting.

Look how small that checker's source code is!
https://clang.llvm.org/extra/doxygen/UseToStringCheck_8cpp_source.html

I have a small match and replace function but I need to figure out how to run it on everything.

And I wasn't using clang-tidy as a platform. I was using clang.
I was trying to avoid writing my tool INSIDE the llvm source tree, and this is the only way I found to do that. But I might have to look harder.

Comment by Alex Neben [ 22/Jul/22 ]

I add the boost-use-to-string clang-tidy check in this variant

https://spruce.mongodb.com/task/mongodb_mongo_master_enterprise_rhel80_dynamic_clang_tidy_condensed_clang_tidy_condensed_e37f9d5efff9974a4a66b6a84bf98f24c1052937_22_07_21_22_10_59/logs?execution=0

It finds uses of "boost::lexical_cast<std::string>" and replaces them with "std::to_string". Just thought if you were doing replace boost stuff with the stl version and replacing the headers you might find this interesting.

Comment by Billy Donahue [ 22/Jul/22 ]

Branch showing how to get away from boost/optional_io.hpp again:
https://github.com/10gen/mongo/compare/master...billydonahue/std_optional


Rudimentary clangAST tool that does two things:

  • replace boost::optional<T> .get() with .value() calls.
  • replace boost::optional<T> .is_initialized() with .has_value() calls.

https://github.com/BillyDonahue/mongo_std_optional_migration

Comment by Billy Donahue [ 20/Jul/22 ]

Older effort (bitrotted obviously) that I'm rehabilitating and updating.
https://github.com/mongodb/mongo/compare/master...BillyDonahue:boost_optional_io_wean?expand=1

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