mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-28 02:37:37 +00:00
Remove the try/catch codepath if swap
is noexcept
.
Summary: In the case where `swap` is `noexcept`, we should avoid the extension to provide strong-exception guarantee. Fixes https://bugs.llvm.org/show_bug.cgi?id=46342 Reviewers: #libc, ldionne Reviewed By: #libc, ldionne Subscribers: dexonsmith, mclow.lists, miscco, ldionne, zoecarver, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D81954
This commit is contained in:
parent
e35ba09961
commit
ada2a8ea4a
@ -1062,7 +1062,16 @@ public:
|
||||
_VSTD::swap(__lhs, __rhs);
|
||||
}
|
||||
__impl __tmp(_VSTD::move(*__rhs));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
static constexpr bool __is_noexcept =
|
||||
#ifdef _LIBCPP_NO_EXCEPTIONS
|
||||
true;
|
||||
#else
|
||||
__all<(is_nothrow_move_constructible_v<_Types> &&
|
||||
is_nothrow_swappable_v<_Types>)...>::value;
|
||||
#endif
|
||||
if constexpr (__is_noexcept) {
|
||||
this->__generic_construct(*__rhs, _VSTD::move(*__lhs));
|
||||
} else {
|
||||
// EXTENSION: When the move construction of `__lhs` into `__rhs` throws
|
||||
// and `__tmp` is nothrow move constructible then we move `__tmp` back
|
||||
// into `__rhs` and provide the strong exception safety guarantee.
|
||||
@ -1074,9 +1083,7 @@ public:
|
||||
}
|
||||
throw;
|
||||
}
|
||||
#else
|
||||
this->__generic_construct(*__rhs, _VSTD::move(*__lhs));
|
||||
#endif
|
||||
}
|
||||
this->__generic_construct(*__lhs, _VSTD::move(__tmp));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user