Skip to content

Commit

Permalink
Revert "[1/N] Add -Wdeprecated and related fixes (pytorch#108626)"
Browse files Browse the repository at this point in the history
This reverts commit a53a677.

Reverted pytorch#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](pytorch#108626 (comment)))
  • Loading branch information
pytorchmergebot committed Sep 20, 2023
1 parent db6e9f6 commit 1cc052b
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 55 deletions.
7 changes: 5 additions & 2 deletions c10/core/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ struct Event final {
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;
Expand Down
3 changes: 3 additions & 0 deletions c10/core/impl/FakeGuardImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ struct FakeGuardImpl final : public DeviceGuardImplInterface {
template <DeviceType T>
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};
Expand Down
4 changes: 0 additions & 4 deletions c10/core/impl/VirtualGuardImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ class VirtualGuardImpl final : public DeviceGuardImplInterface {
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();
Expand Down
2 changes: 2 additions & 0 deletions c10/cuda/impl/CUDAGuardImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ namespace c10 {
namespace cuda {
namespace impl {

constexpr DeviceType CUDAGuardImpl::static_type;

C10_REGISTER_GUARD_IMPL(CUDA, CUDAGuardImpl);

} // namespace impl
Expand Down
12 changes: 4 additions & 8 deletions c10/util/MaybeOwned.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ class MaybeOwned final {
}

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_);
Expand All @@ -137,10 +136,7 @@ class MaybeOwned final {
}

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;
}
Expand All @@ -161,6 +157,7 @@ class MaybeOwned final {
isBorrowed_ = false;
}
}
TORCH_INTERNAL_ASSERT_DEBUG_ONLY(isBorrowed_ == rhs.isBorrowed_);
return *this;
}

Expand All @@ -178,8 +175,7 @@ class MaybeOwned final {
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 {
Expand Down
57 changes: 34 additions & 23 deletions c10/util/Optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -199,9 +213,6 @@ union constexpr_storage_t {
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;
};

Expand Down Expand Up @@ -429,11 +440,6 @@ struct trivially_copyable_optimization_optional_base {
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 {
Expand Down Expand Up @@ -682,15 +688,14 @@ class optional : private OptionalBase<T> {

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 {
Expand Down Expand Up @@ -784,8 +789,9 @@ class optional : private OptionalBase<T> {

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
Expand All @@ -797,15 +803,19 @@ class optional : private OptionalBase<T> {
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)());
}

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)());
Expand Down Expand Up @@ -870,11 +880,10 @@ class optional<T&> {
// 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;
}
Expand Down Expand Up @@ -1253,6 +1262,8 @@ struct hash<c10::optional<T&>> {
#undef TR2_OPTIONAL_ASSERTED_EXPRESSION
#undef TR2_OPTIONAL_HOST_CONSTEXPR

C10_CLANG_DIAGNOSTIC_POP()

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#endif
Expand Down
26 changes: 8 additions & 18 deletions c10/util/SmallVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -1022,9 +1022,7 @@ class SmallVectorImpl : public SmallVectorTemplateBase<T> {

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())
Expand Down Expand Up @@ -1129,9 +1127,7 @@ SmallVectorImpl<T>& SmallVectorImpl<T>::operator=(
}

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;
Expand Down Expand Up @@ -1343,9 +1339,7 @@ class /* LLVM_GSL_OWNER */ SmallVector : public SmallVectorImpl<T>,
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));
}
Expand All @@ -1366,26 +1360,22 @@ class /* LLVM_GSL_OWNER */ SmallVector : public SmallVectorImpl<T>,
.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;
}
Expand All @@ -1406,7 +1396,7 @@ class /* LLVM_GSL_OWNER */ SmallVector : public SmallVectorImpl<T>,
.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;
}
Expand Down
2 changes: 2 additions & 0 deletions test/cpp/jit/test_lite_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2202,6 +2202,8 @@ class LiteInterpreterDynamicTypeTestFixture
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
Expand Down

0 comments on commit 1cc052b

Please sign in to comment.