std::optional::value()
has undesired exception checking semantics and calls __throw_bad_optional_access
in libc++. Moreover, the API is unavailable without _LIBCPP_NO_EXCEPTIONS on older Mach-O platforms (e.g. macOS<10.13), see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
in libcxx/.
At this point, the only practical approach is to migrate value()
to operator*
(and sometimes operator->
or value_or
). We’ll have to find previous llvm::Optional::getValue
call sites like
611ffcf4e4a2ab19063174f6990969f96e9078de and change them to operator*
.
My language server says there are 400+ references.
… but that’s likely going to be a fairly annoying thing to fix going forward.
Hopefully not many people use value()
. Many have learned to discourage std::vector::at
in favor of operator[]
.
I think llvm::Optional::value
needs LLVM_DEPRECATED
to discourage uses.