diff options
author | Markus Böck <markus.boeck02@gmail.com> | 2022-12-17 22:42:30 +0100 |
---|---|---|
committer | Markus Böck <markus.boeck02@gmail.com> | 2022-12-18 00:02:03 +0100 |
commit | 1d43966bc33a55cad1db7758bf4d82526d125db7 (patch) | |
tree | 79be234ffb40d8ac69833b4cc9c44cc70a1b8849 /clang/unittests/Basic/FileManagerTest.cpp | |
parent | 1792821c8308755593c114c3b7ae8ce33bdb08e9 (diff) | |
download | llvm-1d43966bc33a55cad1db7758bf4d82526d125db7.zip llvm-1d43966bc33a55cad1db7758bf4d82526d125db7.tar.gz llvm-1d43966bc33a55cad1db7758bf4d82526d125db7.tar.bz2 |
[llvm][ADT] Allow returning `std::nullopt` in TypeSwitch
Returning `std::nullopt` from the case of a `TypeSwitch` yields broken results, by either falling through to another case, or falling of the switch entirely and hitting an assertion. This is simply due to the use of `operator=` of what is now `std::optional`, which has an overload specifically for `std::nullopt`, causing the internal optional, used for the `TypeSwitch` result to be reset, instead of a value being constructed from the `std::nullopt`.
The fix is to simply use the `emplace` method of `std::optional`, causing a value to always be constructed from the value returned by the case function.
Differential Revision: https://reviews.llvm.org/D140265
Diffstat (limited to 'clang/unittests/Basic/FileManagerTest.cpp')
0 files changed, 0 insertions, 0 deletions