Skip to content

Commit

Permalink
[libc++][test] Add '-Wdeprecated-copy', '-Wdeprecated-copy-dtor' warn…
Browse files Browse the repository at this point in the history
…ings to the test suite

This is a follow up to https://reviews.llvm.org/D144694.
Fixes #60977.

Differential Revision: https://reviews.llvm.org/D144775
  • Loading branch information
fsb4000 authored and ldionne committed Sep 12, 2023
1 parent ec0f678 commit 7024892
Show file tree
Hide file tree
Showing 36 changed files with 97 additions and 6 deletions.
5 changes: 4 additions & 1 deletion libcxx/include/__exception/exception.h
Expand Up @@ -72,7 +72,8 @@ class bad_exception : public exception {
class _LIBCPP_EXPORTED_FROM_ABI exception {
public:
_LIBCPP_HIDE_FROM_ABI exception() _NOEXCEPT {}
_LIBCPP_HIDE_FROM_ABI exception(const exception&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI exception(const exception&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI exception& operator=(const exception&) _NOEXCEPT = default;

virtual ~exception() _NOEXCEPT;
virtual const char* what() const _NOEXCEPT;
Expand All @@ -81,6 +82,8 @@ class _LIBCPP_EXPORTED_FROM_ABI exception {
class _LIBCPP_EXPORTED_FROM_ABI bad_exception : public exception {
public:
_LIBCPP_HIDE_FROM_ABI bad_exception() _NOEXCEPT {}
_LIBCPP_HIDE_FROM_ABI bad_exception(const bad_exception&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_exception& operator=(const bad_exception&) _NOEXCEPT = default;
~bad_exception() _NOEXCEPT override;
const char* what() const _NOEXCEPT override;
};
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/__exception/nested_exception.h
Expand Up @@ -33,8 +33,8 @@ class _LIBCPP_EXPORTED_FROM_ABI nested_exception {

public:
nested_exception() _NOEXCEPT;
// nested_exception(const nested_exception&) noexcept = default;
// nested_exception& operator=(const nested_exception&) noexcept = default;
_LIBCPP_HIDE_FROM_ABI nested_exception(const nested_exception&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI nested_exception& operator=(const nested_exception&) _NOEXCEPT = default;
virtual ~nested_exception() _NOEXCEPT;

// access functions
Expand Down
4 changes: 4 additions & 0 deletions libcxx/include/__expected/expected.h
Expand Up @@ -928,6 +928,8 @@ class expected {
requires(is_trivially_move_constructible_v<_ValueType> && is_trivially_move_constructible_v<_ErrorType>)
union __union_t<_ValueType, _ErrorType> {
_LIBCPP_HIDE_FROM_ABI constexpr __union_t() : __empty_() {}
_LIBCPP_HIDE_FROM_ABI constexpr __union_t(const __union_t&) = default;
_LIBCPP_HIDE_FROM_ABI constexpr __union_t& operator=(const __union_t&) = default;

template <class _Func, class... _Args>
_LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(
Expand Down Expand Up @@ -1529,6 +1531,8 @@ class expected<_Tp, _Err> {
requires is_trivially_move_constructible_v<_ErrorType>
union __union_t<_ErrorType> {
_LIBCPP_HIDE_FROM_ABI constexpr __union_t() : __empty_() {}
_LIBCPP_HIDE_FROM_ABI constexpr __union_t(const __union_t&) = default;
_LIBCPP_HIDE_FROM_ABI constexpr __union_t& operator=(const __union_t&) = default;

template <class _Func, class... _Args>
_LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(
Expand Down
2 changes: 2 additions & 0 deletions libcxx/include/__format/format_error.h
Expand Up @@ -30,6 +30,8 @@ class _LIBCPP_EXPORTED_FROM_ABI format_error : public runtime_error {
: runtime_error(__s) {}
_LIBCPP_HIDE_FROM_ABI explicit format_error(const char* __s)
: runtime_error(__s) {}
_LIBCPP_HIDE_FROM_ABI format_error(const format_error&) = default;
_LIBCPP_HIDE_FROM_ABI format_error& operator=(const format_error&) = default;
_LIBCPP_HIDE_FROM_ABI_VIRTUAL
~format_error() noexcept override = default;
};
Expand Down
3 changes: 3 additions & 0 deletions libcxx/include/__functional/function.h
Expand Up @@ -57,6 +57,9 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_function_call
: public exception
{
public:
_LIBCPP_HIDE_FROM_ABI bad_function_call() _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_function_call(const bad_function_call&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_function_call& operator=(const bad_function_call&) _NOEXCEPT = default;
// Note that when a key function is not used, every translation unit that uses
// bad_function_call will end up containing a weak definition of the vtable and
// typeinfo.
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__memory/shared_ptr.h
Expand Up @@ -126,6 +126,7 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_weak_ptr
public:
_LIBCPP_HIDE_FROM_ABI bad_weak_ptr() _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_weak_ptr(const bad_weak_ptr&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_weak_ptr& operator=(const bad_weak_ptr&) _NOEXCEPT = default;
~bad_weak_ptr() _NOEXCEPT override;
const char* what() const _NOEXCEPT override;
};
Expand Down
4 changes: 4 additions & 0 deletions libcxx/include/new
Expand Up @@ -133,6 +133,8 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_alloc
{
public:
bad_alloc() _NOEXCEPT;
_LIBCPP_HIDE_FROM_ABI bad_alloc(const bad_alloc&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_alloc& operator=(const bad_alloc&) _NOEXCEPT = default;
~bad_alloc() _NOEXCEPT override;
const char* what() const _NOEXCEPT override;
};
Expand All @@ -142,6 +144,8 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_array_new_length
{
public:
bad_array_new_length() _NOEXCEPT;
_LIBCPP_HIDE_FROM_ABI bad_array_new_length(const bad_array_new_length&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_array_new_length& operator=(const bad_array_new_length&) _NOEXCEPT = default;
~bad_array_new_length() _NOEXCEPT override;
const char* what() const _NOEXCEPT override;
};
Expand Down
3 changes: 3 additions & 0 deletions libcxx/include/optional
Expand Up @@ -249,6 +249,9 @@ class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_opt
: public exception
{
public:
_LIBCPP_HIDE_FROM_ABI bad_optional_access() _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_optional_access(const bad_optional_access&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_optional_access& operator=(const bad_optional_access&) _NOEXCEPT = default;
// Get the key function ~bad_optional_access() into the dylib
~bad_optional_access() _NOEXCEPT override;
const char* what() const _NOEXCEPT override;
Expand Down
7 changes: 7 additions & 0 deletions libcxx/include/stdexcept
Expand Up @@ -129,6 +129,7 @@ public:

#ifndef _LIBCPP_ABI_VCRUNTIME
_LIBCPP_HIDE_FROM_ABI domain_error(const domain_error&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI domain_error& operator=(const domain_error&) _NOEXCEPT = default;
~domain_error() _NOEXCEPT override;
#endif
};
Expand All @@ -142,6 +143,7 @@ public:

#ifndef _LIBCPP_ABI_VCRUNTIME
_LIBCPP_HIDE_FROM_ABI invalid_argument(const invalid_argument&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI invalid_argument& operator=(const invalid_argument&) _NOEXCEPT = default;
~invalid_argument() _NOEXCEPT override;
#endif
};
Expand All @@ -154,6 +156,7 @@ public:
_LIBCPP_INLINE_VISIBILITY explicit length_error(const char* __s) : logic_error(__s) {}
#ifndef _LIBCPP_ABI_VCRUNTIME
_LIBCPP_HIDE_FROM_ABI length_error(const length_error&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI length_error& operator=(const length_error&) _NOEXCEPT = default;
~length_error() _NOEXCEPT override;
#endif
};
Expand All @@ -167,6 +170,7 @@ public:

#ifndef _LIBCPP_ABI_VCRUNTIME
_LIBCPP_HIDE_FROM_ABI out_of_range(const out_of_range&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI out_of_range& operator=(const out_of_range&) _NOEXCEPT = default;
~out_of_range() _NOEXCEPT override;
#endif
};
Expand All @@ -180,6 +184,7 @@ public:

#ifndef _LIBCPP_ABI_VCRUNTIME
_LIBCPP_HIDE_FROM_ABI range_error(const range_error&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI range_error& operator=(const range_error&) _NOEXCEPT = default;
~range_error() _NOEXCEPT override;
#endif
};
Expand All @@ -193,6 +198,7 @@ public:

#ifndef _LIBCPP_ABI_VCRUNTIME
_LIBCPP_HIDE_FROM_ABI overflow_error(const overflow_error&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI overflow_error& operator=(const overflow_error&) _NOEXCEPT = default;
~overflow_error() _NOEXCEPT override;
#endif
};
Expand All @@ -206,6 +212,7 @@ public:

#ifndef _LIBCPP_ABI_VCRUNTIME
_LIBCPP_HIDE_FROM_ABI underflow_error(const underflow_error&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI underflow_error& operator=(const underflow_error&) _NOEXCEPT = default;
~underflow_error() _NOEXCEPT override;
#endif
};
Expand Down
3 changes: 3 additions & 0 deletions libcxx/include/typeinfo
Expand Up @@ -360,6 +360,7 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_cast
public:
bad_cast() _NOEXCEPT;
_LIBCPP_HIDE_FROM_ABI bad_cast(const bad_cast&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_cast& operator=(const bad_cast&) _NOEXCEPT = default;
~bad_cast() _NOEXCEPT override;
const char* what() const _NOEXCEPT override;
};
Expand All @@ -369,6 +370,8 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_typeid
{
public:
bad_typeid() _NOEXCEPT;
_LIBCPP_HIDE_FROM_ABI bad_typeid(const bad_typeid&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_typeid& operator=(const bad_typeid&) _NOEXCEPT = default;
~bad_typeid() _NOEXCEPT override;
const char* what() const _NOEXCEPT override;
};
Expand Down
Expand Up @@ -29,6 +29,8 @@ class A
int data_;
public:
A() : data_(1) {}
A(const A&) = default;
A& operator=(const A&) = default;
~A() {data_ = -1;}

int get() const {return data_;}
Expand All @@ -50,6 +52,8 @@ class B
int data_;
public:
B(int d=1) : data_(d) {}
B(const B&) = default;
B& operator=(const B&) = default;
~B() {data_ = -1;}

int get() const {return data_;}
Expand Down
Expand Up @@ -27,6 +27,8 @@ class A
int data_;
public:
A() : data_(1) {}
A(const A&) = default;
A& operator=(const A&) = default;
~A() {data_ = -1;}

friend bool operator==(const A& x, const A& y)
Expand Down
Expand Up @@ -24,6 +24,8 @@ struct Node {
int* shared_val;

explicit Node(int* ptr) : shared_val(ptr) {}
Node(const Node&) = default;
Node& operator=(const Node&) = default;
~Node() { ++(*shared_val); }
};

Expand Down
Expand Up @@ -26,6 +26,8 @@ struct Base {

explicit Base(char* buf, int* idx, char ch)
: shared_buff(buf), cur_idx(idx), id(ch) {}
Base(const Base& other) = default;
Base& operator=(const Base&) = delete;
~Base() { shared_buff[(*cur_idx)++] = id; }
};

Expand Down
2 changes: 2 additions & 0 deletions libcxx/test/libcxx/memory/trivial_abi/unique_ptr_ret.pass.cpp
Expand Up @@ -21,6 +21,8 @@ __attribute__((noinline)) void call_something() { asm volatile(""); }

struct Node {
explicit Node() {}
Node(const Node&) = default;
Node& operator=(const Node&) = default;
~Node() {}
};

Expand Down
2 changes: 2 additions & 0 deletions libcxx/test/libcxx/memory/trivial_abi/weak_ptr_ret.pass.cpp
Expand Up @@ -21,6 +21,8 @@ __attribute__((noinline)) void call_something() { asm volatile(""); }

struct Node {
explicit Node() {}
Node(const Node&) = default;
Node& operator=(const Node&) = default;
~Node() {}
};

Expand Down
Expand Up @@ -24,6 +24,9 @@ struct A
static std::function<void()> global;
static bool cancel;

A() = default;
A(const A&) = default;
A& operator=(const A&) = default;
~A() {
DoNotOptimize(cancel);
if (cancel)
Expand Down
Expand Up @@ -24,6 +24,9 @@ struct A
static std::function<void()> global;
static bool cancel;

A() = default;
A(const A&) = default;
A& operator=(const A&) = default;
~A() {
DoNotOptimize(cancel);
if (cancel)
Expand Down
Expand Up @@ -37,6 +37,8 @@ class Copyable
int data_;
public:
Copyable() : data_(0) {}
Copyable(const Copyable&) = default;
Copyable& operator=(const Copyable&) = default;
~Copyable() {data_ = -1;}

friend bool operator==(const Copyable& x, const Copyable& y)
Expand Down
Expand Up @@ -37,6 +37,8 @@ class Copyable
int data_;
public:
Copyable() : data_(0) {}
Copyable(const Copyable&) = default;
Copyable& operator=(const Copyable&) = default;
~Copyable() {data_ = -1;}

friend bool operator==(const Copyable& x, const Copyable& y)
Expand Down
Expand Up @@ -26,6 +26,8 @@ class A
int data_;
public:
A() : data_(1) {}
A(const A&) = default;
A& operator=(const A&) = default;
~A() {data_ = -1;}

friend bool operator==(const A& x, const A& y)
Expand Down
Expand Up @@ -29,6 +29,8 @@ class A
int data_;
public:
A() : data_(1) {}
A(const A&) = default;
A& operator=(const A&) = default;
~A() {data_ = -1;}

int get() const {return data_;}
Expand All @@ -50,6 +52,8 @@ class B
int data_;
public:
B(int d=1) : data_(d) {}
B(const B&) = default;
B& operator=(const B&) = default;
~B() {data_ = -1;}

int get() const {return data_;}
Expand Down
Expand Up @@ -27,6 +27,8 @@ class A
int data_;
public:
A() : data_(1) {}
A(const A&) = default;
A& operator=(const A&) = default;
~A() {data_ = -1;}

friend bool operator==(const A& x, const A& y)
Expand Down
Expand Up @@ -29,6 +29,9 @@ struct goroutine
rh = nullptr;
}

goroutine() = default;
goroutine(const goroutine&) = default;
goroutine& operator=(const goroutine&) = default;
~goroutine() {}

static void run_one()
Expand Down
Expand Up @@ -22,6 +22,7 @@ struct TrackLifetime {
TrackLifetime(LifetimeInformation& info) : info_(&info) {
info_->address_constructed = this;
}
TrackLifetime(TrackLifetime const&) = default;
~TrackLifetime() {
info_->address_destroyed = this;
}
Expand All @@ -43,6 +44,7 @@ struct alignas(std::max_align_t) TrackLifetimeMaxAligned {
TrackLifetimeMaxAligned(LifetimeInformation& info) : info_(&info) {
info_->address_constructed = this;
}
TrackLifetimeMaxAligned(TrackLifetimeMaxAligned const&) = default;
~TrackLifetimeMaxAligned() {
info_->address_destroyed = this;
}
Expand Down
Expand Up @@ -28,6 +28,8 @@ class A
int data_;
public:
explicit A(int data) : data_(data) {}
A(const A&) = default;
A& operator=(const A&) = default;
virtual ~A() TEST_NOEXCEPT {}

friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
Expand Down
Expand Up @@ -29,6 +29,9 @@ struct ZeroOnDestroy : std::ranges::view_base {
constexpr ForwardIter end() { return ForwardIter(buff + 8); }
constexpr ForwardIter end() const { return ForwardIter(); }

ZeroOnDestroy() = default;
ZeroOnDestroy(const ZeroOnDestroy&) = default;
ZeroOnDestroy& operator=(const ZeroOnDestroy&) = default;
~ZeroOnDestroy() {
std::memset(buff, 0, sizeof(buff));
}
Expand Down
2 changes: 2 additions & 0 deletions libcxx/test/std/utilities/tuple/tuple.tuple/alloc_first.h
Expand Up @@ -44,6 +44,8 @@ struct alloc_first
allocator_constructed = true;
}

alloc_first(const alloc_first&) = default;
alloc_first& operator=(const alloc_first&) = default;
~alloc_first() {data_ = -1;}

friend bool operator==(const alloc_first& x, const alloc_first& y)
Expand Down
2 changes: 2 additions & 0 deletions libcxx/test/std/utilities/tuple/tuple.tuple/alloc_last.h
Expand Up @@ -44,6 +44,8 @@ struct alloc_last
allocator_constructed = true;
}

alloc_last(const alloc_last&) = default;
alloc_last& operator=(const alloc_last&) = default;
~alloc_last() {data_ = -1;}

friend bool operator==(const alloc_last& x, const alloc_last& y)
Expand Down
Expand Up @@ -26,6 +26,8 @@
struct B {
int id_;
explicit B(int i = 0) : id_(i) {}
B(const B&) = default;
B& operator=(const B&) = default;
virtual ~B() {}
};

Expand Down
Expand Up @@ -36,7 +36,8 @@ struct B
int id_;

explicit B(int i) : id_(i) {}

B(const B&) = default;
B& operator=(const B&) = default;
virtual ~B() {}
};

Expand Down

0 comments on commit 7024892

Please sign in to comment.