Revert "[1/N] Add -Wdeprecated and related fixes (#108626)"
This reverts commit a53a677b4d8b9f4b9abbfeed2a6d4c00e9ee2252.
Reverted https://github.com/pytorch/pytorch/pull/108626 on behalf of https://github.com/clee2000 due to I'm getting errors internally that look like the below on x86_64-apple-ios-simulator with clang 16 ([comment](https://github.com/pytorch/pytorch/pull/108626#issuecomment-1728102447))
diff --git a/c10/core/Event.h b/c10/core/Event.h
index 7b43f02..2ed9049 100644
--- a/c10/core/Event.h
+++ b/c10/core/Event.h
@@ -50,8 +50,11 @@
Event& operator=(const Event&) = delete;
// Move constructor and move assignment operator
- Event(Event&&) noexcept = default;
- Event& operator=(Event&&) noexcept = default;
+ Event(Event&& other) noexcept : impl_{std::move(other.impl_)} {}
+ Event& operator=(Event&& other) noexcept {
+ impl_.swap(std::move(other.impl_));
+ return *this;
+ }
// Destructor
~Event() = default;
diff --git a/c10/core/impl/FakeGuardImpl.h b/c10/core/impl/FakeGuardImpl.h
index c9b4721..c862552 100644
--- a/c10/core/impl/FakeGuardImpl.h
+++ b/c10/core/impl/FakeGuardImpl.h
@@ -97,6 +97,9 @@
thread_local DeviceIndex FakeGuardImpl<T>::current_device_ = 0;
template <DeviceType T>
+constexpr DeviceType FakeGuardImpl<T>::static_type;
+
+template <DeviceType T>
thread_local std::array<StreamId, kFakeGuardImplMaxDevices>
FakeGuardImpl<T>::current_streams_ = {0, 0, 0, 0, 0, 0, 0, 0};
diff --git a/c10/core/impl/VirtualGuardImpl.h b/c10/core/impl/VirtualGuardImpl.h
index af12834..1b8da6a 100644
--- a/c10/core/impl/VirtualGuardImpl.h
+++ b/c10/core/impl/VirtualGuardImpl.h
@@ -17,10 +17,6 @@
VirtualGuardImpl(const DeviceGuardImplInterface* impl) : impl_(impl) {}
// Copying and moving is OK!
- VirtualGuardImpl(const VirtualGuardImpl&) = default;
- VirtualGuardImpl& operator=(const VirtualGuardImpl&) = default;
- VirtualGuardImpl(VirtualGuardImpl&&) noexcept = default;
- VirtualGuardImpl& operator=(VirtualGuardImpl&&) noexcept = default;
DeviceType type() const override {
return impl_->type();
diff --git a/c10/cuda/impl/CUDAGuardImpl.cpp b/c10/cuda/impl/CUDAGuardImpl.cpp
index 584430f..6bed0c0 100644
--- a/c10/cuda/impl/CUDAGuardImpl.cpp
+++ b/c10/cuda/impl/CUDAGuardImpl.cpp
@@ -4,6 +4,8 @@
namespace cuda {
namespace impl {
+constexpr DeviceType CUDAGuardImpl::static_type;
+
C10_REGISTER_GUARD_IMPL(CUDA, CUDAGuardImpl);
} // namespace impl
diff --git a/c10/util/MaybeOwned.h b/c10/util/MaybeOwned.h
index 643ff7d..a698e27 100644
--- a/c10/util/MaybeOwned.h
+++ b/c10/util/MaybeOwned.h
@@ -126,8 +126,7 @@
}
MaybeOwned(MaybeOwned&& rhs) noexcept(
- std::is_nothrow_move_constructible_v<T>&&
- std::is_nothrow_move_assignable_v<borrow_type>)
+ std::is_nothrow_move_constructible<T>::value)
: isBorrowed_(rhs.isBorrowed_) {
if (C10_LIKELY(rhs.isBorrowed_)) {
MaybeOwnedTraits<T>::assignBorrow(borrow_, rhs.borrow_);
@@ -137,10 +136,7 @@
}
MaybeOwned& operator=(MaybeOwned&& rhs) noexcept(
- std::is_nothrow_move_assignable_v<T>&& std::is_nothrow_move_assignable_v<
- borrow_type>&& std::is_nothrow_move_constructible_v<T>&&
- std::is_nothrow_destructible_v<T>&&
- std::is_nothrow_destructible_v<borrow_type>) {
+ std::is_nothrow_move_assignable<T>::value) {
if (this == &rhs) {
return *this;
}
@@ -161,6 +157,7 @@
isBorrowed_ = false;
}
}
+ TORCH_INTERNAL_ASSERT_DEBUG_ONLY(isBorrowed_ == rhs.isBorrowed_);
return *this;
}
@@ -178,8 +175,7 @@
return MaybeOwned(in_place, std::forward<Args>(args)...);
}
- ~MaybeOwned() noexcept(std::is_nothrow_destructible_v<T>&&
- std::is_nothrow_destructible_v<borrow_type>) {
+ ~MaybeOwned() {
if (C10_UNLIKELY(!isBorrowed_)) {
own_.~T();
} else {
diff --git a/c10/util/Optional.h b/c10/util/Optional.h
index 1441facc..7b51f07 100644
--- a/c10/util/Optional.h
+++ b/c10/util/Optional.h
@@ -42,6 +42,20 @@
#include <c10/util/C++17.h>
#include <c10/util/Metaprogramming.h>
+C10_CLANG_DIAGNOSTIC_PUSH()
+#if C10_CLANG_HAS_WARNING("-Wstring-conversion")
+C10_CLANG_DIAGNOSTIC_IGNORE("-Wstring-conversion")
+#endif
+#if C10_CLANG_HAS_WARNING("-Wshorten-64-to-32")
+C10_CLANG_DIAGNOSTIC_IGNORE("-Wshorten-64-to-32")
+#endif
+#if C10_CLANG_HAS_WARNING("-Wimplicit-float-conversion")
+C10_CLANG_DIAGNOSTIC_IGNORE("-Wimplicit-float-conversion")
+#endif
+#if C10_CLANG_HAS_WARNING("-Wimplicit-int-conversion")
+C10_CLANG_DIAGNOSTIC_IGNORE("-Wimplicit-int-conversion")
+#endif
+
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable : 4624) // destructor was implicitly defined as deleted
@@ -199,9 +213,6 @@
constexpr constexpr_storage_t(Args&&... args)
: value_(constexpr_forward<Args>(args)...) {}
- constexpr constexpr_storage_t(const constexpr_storage_t&) = default;
- constexpr constexpr_storage_t& operator=(const constexpr_storage_t&) =
- default;
~constexpr_storage_t() = default;
};
@@ -429,11 +440,6 @@
Args&&... args)
: init_(true), storage_(il, std::forward<Args>(args)...) {}
- constexpr trivially_copyable_optimization_optional_base(
- const trivially_copyable_optimization_optional_base&) = default;
-
- constexpr trivially_copyable_optimization_optional_base& operator=(
- const trivially_copyable_optimization_optional_base&) = default;
~trivially_copyable_optimization_optional_base() = default;
constexpr bool initialized() const noexcept {
@@ -682,15 +688,14 @@
optional& operator=(optional&& rhs) = default;
- template <
- class U = T,
- typename = std::enable_if_t<
- std::is_constructible<T, U>::value &&
+ template <class U = T>
+ auto operator=(U&& v) -> typename std::enable_if<
+ std::is_constructible<T, U>::value &&
!std::is_same<typename std::decay<U>::type, optional<T>>::value &&
(std::is_scalar<T>::value ||
std::is_same<typename std::decay<U>::type, T>::value) &&
- std::is_assignable<T&, U>::value>>
- optional& operator=(U&& v) {
+ std::is_assignable<T&, U>::value,
+ optional&>::type {
if (initialized()) {
contained_val() = std::forward<U>(v);
} else {
@@ -784,8 +789,9 @@
template <class V>
constexpr T value_or(V&& v) && {
- return *this ? constexpr_move(*this).contained_val()
- : detail_::convert<T>(constexpr_forward<V>(v));
+ return *this
+ ? constexpr_move(const_cast<optional<T>&>(*this).contained_val())
+ : detail_::convert<T>(constexpr_forward<V>(v));
}
// 20.6.3.6, modifiers
@@ -797,7 +803,9 @@
template <class T, class F>
constexpr T value_or_else(const optional<T>& v, F&& func) {
static_assert(
- std::is_convertible<typename std::invoke_result_t<F>, T>::value,
+ std::is_convertible<
+ typename guts::infer_function_traits_t<F>::return_type,
+ T>::value,
"func parameters must be a callable that returns a type convertible to the value stored in the optional");
return v.has_value() ? *v : detail_::convert<T>(std::forward<F>(func)());
}
@@ -805,7 +813,9 @@
template <class T, class F>
constexpr T value_or_else(optional<T>&& v, F&& func) {
static_assert(
- std::is_convertible<typename std::invoke_result_t<F>, T>::value,
+ std::is_convertible<
+ typename guts::infer_function_traits_t<F>::return_type,
+ T>::value,
"func parameters must be a callable that returns a type convertible to the value stored in the optional");
return v.has_value() ? constexpr_move(std::move(v).contained_val())
: detail_::convert<T>(std::forward<F>(func)());
@@ -870,11 +880,10 @@
// return *this;
// }
- template <
- typename U,
- typename = std::enable_if_t<
- std::is_same_v<typename std::decay<U>::type, optional<T&>>>>
- optional& operator=(U&& rhs) noexcept {
+ template <typename U>
+ auto operator=(U&& rhs) noexcept -> typename std::enable_if<
+ std::is_same<typename std::decay<U>::type, optional<T&>>::value,
+ optional&>::type {
ref = rhs.ref;
return *this;
}
@@ -1253,6 +1262,8 @@
#undef TR2_OPTIONAL_ASSERTED_EXPRESSION
#undef TR2_OPTIONAL_HOST_CONSTEXPR
+C10_CLANG_DIAGNOSTIC_POP()
+
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#endif
diff --git a/c10/util/SmallVector.h b/c10/util/SmallVector.h
index a5f6d7f..3427a6e 100644
--- a/c10/util/SmallVector.h
+++ b/c10/util/SmallVector.h
@@ -1022,9 +1022,7 @@
SmallVectorImpl& operator=(const SmallVectorImpl& RHS);
- SmallVectorImpl& operator=(SmallVectorImpl&& RHS) noexcept(
- std::is_nothrow_move_constructible_v<T>&&
- std::is_nothrow_destructible_v<T>);
+ SmallVectorImpl& operator=(SmallVectorImpl&& RHS);
bool operator==(const SmallVectorImpl& RHS) const {
if (this->size() != RHS.size())
@@ -1129,9 +1127,7 @@
}
template <typename T>
-SmallVectorImpl<T>& SmallVectorImpl<T>::operator=(
- SmallVectorImpl<T>&& RHS) noexcept(std::is_nothrow_move_constructible_v<T>&&
- std::is_nothrow_destructible_v<T>) {
+SmallVectorImpl<T>& SmallVectorImpl<T>::operator=(SmallVectorImpl<T>&& RHS) {
// Avoid self-assignment.
if (this == &RHS)
return *this;
@@ -1343,9 +1339,7 @@
return *this;
}
- SmallVector(SmallVector&& RHS) noexcept(
- std::is_nothrow_move_assignable_v<SmallVectorImpl<T>>)
- : SmallVectorImpl<T>(N) {
+ SmallVector(SmallVector&& RHS) : SmallVectorImpl<T>(N) {
if (!RHS.empty())
SmallVectorImpl<T>::operator=(::std::move(RHS));
}
@@ -1366,26 +1360,22 @@
.end())>::iterator_category,
std::input_iterator_tag>::value,
int> = 0>
- SmallVector& operator=(const Container& RHS) {
+ const SmallVector& operator=(const Container& RHS) {
this->assign(RHS.begin(), RHS.end());
return *this;
}
- SmallVector(SmallVectorImpl<T>&& RHS) noexcept(
- std::is_nothrow_move_assignable_v<SmallVectorImpl<T>>)
- : SmallVectorImpl<T>(N) {
+ SmallVector(SmallVectorImpl<T>&& RHS) : SmallVectorImpl<T>(N) {
if (!RHS.empty())
SmallVectorImpl<T>::operator=(::std::move(RHS));
}
- SmallVector& operator=(SmallVector&& RHS) noexcept(
- std::is_nothrow_move_assignable_v<SmallVectorImpl<T>>) {
+ SmallVector& operator=(SmallVector&& RHS) {
SmallVectorImpl<T>::operator=(::std::move(RHS));
return *this;
}
- SmallVector& operator=(SmallVectorImpl<T>&& RHS) noexcept(
- std::is_nothrow_move_constructible_v<SmallVectorImpl<T>>) {
+ SmallVector& operator=(SmallVectorImpl<T>&& RHS) {
SmallVectorImpl<T>::operator=(::std::move(RHS));
return *this;
}
@@ -1406,7 +1396,7 @@
.end())>::iterator_category,
std::input_iterator_tag>::value,
int> = 0>
- SmallVector& operator=(Container&& C) {
+ const SmallVector& operator=(Container&& C) {
this->assign(C.begin(), C.end());
return *this;
}
diff --git a/test/cpp/jit/test_lite_interpreter.cpp b/test/cpp/jit/test_lite_interpreter.cpp
index 01385c5..e583d57 100644
--- a/test/cpp/jit/test_lite_interpreter.cpp
+++ b/test/cpp/jit/test_lite_interpreter.cpp
@@ -2202,6 +2202,8 @@
static constexpr size_t kNumSplits = 10;
};
+constexpr size_t LiteInterpreterDynamicTypeTestFixture::kNumSplits;
+
/**
* Enumerate all possible JIT types appearing in mobile runtime, and test
* whether subtyping relation is preserved after one of the JIT types is