[clang] [clang][Interp] Handle std::move etc. builtins (PR #70772)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 8 09:52:46 PST 2023
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/70772 at github.com>
================
@@ -378,3 +378,92 @@ namespace Packs {
static_assert(foo<int, char>() == 2, "");
static_assert(foo<>() == 0, "");
}
+
+namespace std {
+template <typename T> struct remove_reference { using type = T; };
+template <typename T> struct remove_reference<T &> { using type = T; };
+template <typename T> struct remove_reference<T &&> { using type = T; };
+template <typename T>
+constexpr typename std::remove_reference<T>::type&& move(T &&t) noexcept {
+ return static_cast<typename std::remove_reference<T>::type &&>(t);
+}
+}
+/// The std::move declaration above gets translated to a builtin function.
+namespace Move {
----------------
AaronBallman wrote:
I'd like to see test coverage involving a move constructor, a move assignment operator, a direct call to __builtin_move, and some testing for `std::as_const` and `std::forward`. Of special interest would be times when there's UB in the move constructor/move assignment that should be caught or a non-copyable object where move semantics are the only thing that should work.
https://github.com/llvm/llvm-project/pull/70772
More information about the cfe-commits
mailing list